@saar-ai/web-widget 0.16.2 → 0.18.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-DzSK1ZIU.js → chat-DHMjOVms.js} +1 -1
- package/dist/chunks/{esm-D2iq2DjO.js → esm-5fDiLoFP.js} +4 -4
- package/dist/chunks/{form-fill-dom-skU-ZwLB.js → form-fill-dom-D4ZMwxX1.js} +1 -1
- package/dist/chunks/{host-widget-BA1HJzO_.js → host-widget-BhtqtvaY.js} +1856 -1181
- package/dist/chunks/{livekit-client.esm-OPuvn_z-.js → livekit-client.esm-BSWImnve.js} +27 -21
- package/dist/chunks/{schemas-DC_oWrTO.js → schemas-DgC5Pex0.js} +16 -11
- package/dist/chunks/{telemetry-UHSrhVyf.js → telemetry-ZeV7hBI7.js} +1 -1
- 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.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/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 +5 -5
- package/dist/messages.d.ts +10 -3
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/spoken-transcript.d.ts +113 -0
- package/dist/spoken-transcript.d.ts.map +1 -0
- 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/use-voice-session.d.ts +9 -2
- package/dist/use-voice-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +38 -3
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget/call-view.d.ts +146 -0
- package/dist/widget/call-view.d.ts.map +1 -0
- package/dist/widget/concierge-launcher.d.ts +21 -2
- package/dist/widget/concierge-launcher.d.ts.map +1 -1
- package/dist/widget/concierge-shell.d.ts +49 -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 +27 -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.css +1 -1
- package/package.json +16 -4
- package/src/styles/call-view.css +280 -0
- package/src/styles/concierge-shell-entry.css +10 -0
- package/src/styles/mark.css +94 -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`. */
|
|
@@ -4621,6 +4647,7 @@ var defaultWidgetMessages = {
|
|
|
4621
4647
|
handback_event: "Back with the concierge",
|
|
4622
4648
|
capture_saved_event: "Thanks — sent.",
|
|
4623
4649
|
capture_declined_event: "No problem — skipped.",
|
|
4650
|
+
call_started_event: "Call started",
|
|
4624
4651
|
escalated_banner: "A human teammate will pick this up shortly.",
|
|
4625
4652
|
status_sending: "Queued",
|
|
4626
4653
|
status_sent: "Delivered",
|
|
@@ -5249,7 +5276,7 @@ function deriveText(surfaceHex) {
|
|
|
5249
5276
|
C: TEXT_C,
|
|
5250
5277
|
h: hue
|
|
5251
5278
|
});
|
|
5252
|
-
if (contrastRatio(candidate, surfaceHex) >=
|
|
5279
|
+
if (contrastRatio(candidate, surfaceHex) >= 4.5) return candidate;
|
|
5253
5280
|
const next = Number((L + step).toFixed(4));
|
|
5254
5281
|
if (next < 0 || next > 1) break;
|
|
5255
5282
|
L = next;
|
|
@@ -5312,8 +5339,8 @@ function deriveText(surfaceHex) {
|
|
|
5312
5339
|
* a mid-lightness surface can be unreachable from one side and comfortable
|
|
5313
5340
|
* from the other.
|
|
5314
5341
|
*/
|
|
5315
|
-
function deriveRing(primaryHex, surfaceHex) {
|
|
5316
|
-
if (contrastRatio(primaryHex, surfaceHex) >=
|
|
5342
|
+
function deriveRing(primaryHex, surfaceHex, floor = RING_CONTRAST_MIN) {
|
|
5343
|
+
if (contrastRatio(primaryHex, surfaceHex) >= floor) return primaryHex;
|
|
5317
5344
|
const primary = hexToOklch(primaryHex);
|
|
5318
5345
|
const preferDark = hexToOklch(surfaceHex).L >= .5;
|
|
5319
5346
|
for (const goDark of preferDark ? [true, false] : [false, true]) {
|
|
@@ -5328,7 +5355,7 @@ function deriveRing(primaryHex, surfaceHex) {
|
|
|
5328
5355
|
C: primary.C,
|
|
5329
5356
|
h: primary.h
|
|
5330
5357
|
});
|
|
5331
|
-
if (contrastRatio(candidate, surfaceHex) >=
|
|
5358
|
+
if (contrastRatio(candidate, surfaceHex) >= floor) return candidate;
|
|
5332
5359
|
}
|
|
5333
5360
|
}
|
|
5334
5361
|
return contrastRatio("#000000", surfaceHex) >= contrastRatio("#ffffff", surfaceHex) ? "#000000" : "#ffffff";
|
|
@@ -5385,8 +5412,8 @@ function deriveTheme(color, type) {
|
|
|
5385
5412
|
dark: deriveVars(color, type, supplied && suppliedIsDark ? supplied : DEFAULT_DARK_SURFACE)
|
|
5386
5413
|
};
|
|
5387
5414
|
}
|
|
5388
|
-
function block(vars, selector, indent) {
|
|
5389
|
-
return `${indent}${selector} {\n${
|
|
5415
|
+
function block(vars, selector, indent, tokens) {
|
|
5416
|
+
return `${indent}${selector} {\n${tokens.map((t) => `${indent} ${t}: ${vars[t]};`).join("\n")}\n${indent}}`;
|
|
5390
5417
|
}
|
|
5391
5418
|
/**
|
|
5392
5419
|
* The theme as a CSS text block: the unconditional rule, plus — for
|
|
@@ -5404,12 +5431,12 @@ function block(vars, selector, indent) {
|
|
|
5404
5431
|
* `:host` is the default because the dock lives in a shadow root; pass a class
|
|
5405
5432
|
* or `:root` for the console preview, which renders in light DOM.
|
|
5406
5433
|
*/
|
|
5407
|
-
function themeToCss(theme, selector = ":host") {
|
|
5408
|
-
let css = `${block(theme.light, selector, "")}\n`;
|
|
5434
|
+
function themeToCss(theme, selector = ":host", tokens = WIDGET_THEME_TOKENS) {
|
|
5435
|
+
let css = `${block(theme.light, selector, "", tokens)}\n`;
|
|
5409
5436
|
if (theme.dark) {
|
|
5410
5437
|
const host = selector === ":host";
|
|
5411
|
-
css += `\n@media (prefers-color-scheme: dark) {\n${block(theme.dark, host ? `:host(:not(${TONE_MARK}"light"]))` : selector, " ")}\n}\n`;
|
|
5412
|
-
if (host) css += `\n${block(theme.dark, `:host(${TONE_MARK}"dark"])`, "")}\n`;
|
|
5438
|
+
css += `\n@media (prefers-color-scheme: dark) {\n${block(theme.dark, host ? `:host(:not(${TONE_MARK}"light"]))` : selector, " ", tokens)}\n}\n`;
|
|
5439
|
+
if (host) css += `\n${block(theme.dark, `:host(${TONE_MARK}"dark"])`, "", tokens)}\n`;
|
|
5413
5440
|
}
|
|
5414
5441
|
return css;
|
|
5415
5442
|
}
|
|
@@ -5420,9 +5447,20 @@ var TONE_MARK = "[data-wgt-tone=";
|
|
|
5420
5447
|
* host page's tone beats the media query on that element too. Matches
|
|
5421
5448
|
* nothing in light DOM. Empty unless the tone is `auto`.
|
|
5422
5449
|
*/
|
|
5423
|
-
function themeToMarkedHostCss(theme, selector) {
|
|
5450
|
+
function themeToMarkedHostCss(theme, selector, tokens = WIDGET_THEME_TOKENS) {
|
|
5424
5451
|
if (!theme.dark) return "";
|
|
5425
|
-
return `${block(theme.light, `:host(${TONE_MARK}"light"]) ${selector}`, "")}\n\n${block(theme.dark, `:host(${TONE_MARK}"dark"]) ${selector}`, "")}\n`;
|
|
5452
|
+
return `${block(theme.light, `:host(${TONE_MARK}"light"]) ${selector}`, "", tokens)}\n\n${block(theme.dark, `:host(${TONE_MARK}"dark"]) ${selector}`, "", tokens)}\n`;
|
|
5453
|
+
}
|
|
5454
|
+
/**
|
|
5455
|
+
* The tenant's tokens for one scoped element (`[data-wgt-scope]`), with the
|
|
5456
|
+
* host's tone marks on it; `host` adds a `:host` block first, for an element
|
|
5457
|
+
* that renders in a shadow root as well as in light DOM. Two blocks with the
|
|
5458
|
+
* same body rather than one selector list, because one invalid selector
|
|
5459
|
+
* invalidates a whole rule.
|
|
5460
|
+
*/
|
|
5461
|
+
function scopedThemeCss(theme, scope, tokens = WIDGET_THEME_TOKENS, host = false) {
|
|
5462
|
+
const css = `${themeToCss(theme, scope, tokens)}\n${themeToMarkedHostCss(theme, scope, tokens)}`;
|
|
5463
|
+
return host ? `${themeToCss(theme, ":host", tokens)}\n${css}` : css;
|
|
5426
5464
|
}
|
|
5427
5465
|
/**
|
|
5428
5466
|
* The theme as a `style` attribute value, for the `core` stage — which paints
|
|
@@ -5433,8 +5471,8 @@ function themeToMarkedHostCss(theme, selector) {
|
|
|
5433
5471
|
* current `prefers-color-scheme` and the adopted stylesheet takes over the
|
|
5434
5472
|
* responsiveness at the React handover.
|
|
5435
5473
|
*/
|
|
5436
|
-
function themeToInlineStyle(vars) {
|
|
5437
|
-
return
|
|
5474
|
+
function themeToInlineStyle(vars, tokens = WIDGET_THEME_TOKENS) {
|
|
5475
|
+
return tokens.map((t) => `${t}:${vars[t]};`).join("");
|
|
5438
5476
|
}
|
|
5439
5477
|
//#endregion
|
|
5440
5478
|
//#region src/dock/geometry.ts
|
|
@@ -5442,8 +5480,7 @@ function themeToInlineStyle(vars) {
|
|
|
5442
5480
|
* DOCK GEOMETRY — every length the dock's row, pill and sheet are built from
|
|
5443
5481
|
* (docs/DOCK_SPEC.md §3), and the CSS expressions that carry them.
|
|
5444
5482
|
*
|
|
5445
|
-
* ONE module owns all of it
|
|
5446
|
-
* owns the panel's four lengths: the dock is drawn TWICE, by two renderers
|
|
5483
|
+
* ONE module owns all of it because the dock is drawn TWICE, by two renderers
|
|
5447
5484
|
* with no shared runtime. The CDN `core` stage paints the resting row and the
|
|
5448
5485
|
* pill in plain DOM before any framework loads, writing these values as an
|
|
5449
5486
|
* inline `style` attribute; the React dock then adopts a stylesheet built
|
|
@@ -5520,7 +5557,7 @@ var DESKTOP_WIDTHS = {
|
|
|
5520
5557
|
full: null
|
|
5521
5558
|
};
|
|
5522
5559
|
/** §9.1 `type.radius`, in px. Mirrors `theme/derive.ts`'s `--wgt-radius`. */
|
|
5523
|
-
var RADII = {
|
|
5560
|
+
var RADII$1 = {
|
|
5524
5561
|
square: 0,
|
|
5525
5562
|
soft: 12,
|
|
5526
5563
|
round: 20,
|
|
@@ -6874,7 +6911,7 @@ function DockMarkFace({ identity, mark, size, testId, handoff, operatorName }) {
|
|
|
6874
6911
|
const initials = handoff === true ? handoffInitials(operatorName) : "";
|
|
6875
6912
|
const handoffKind = handoff !== true ? void 0 : initials === "" ? "person" : "initials";
|
|
6876
6913
|
const url = handoffKind === void 0 && identity.avatar === "image" ? safeAvatarUrl(identity.avatarUrl) : void 0;
|
|
6877
|
-
const kind = url ? "image" : identity.avatar === "image" ? "none" : identity.avatar;
|
|
6914
|
+
const kind = url ? "image" : identity.avatar === "image" ? "none" : dockAvatarFor(identity.avatar);
|
|
6878
6915
|
return /* @__PURE__ */ jsx("span", {
|
|
6879
6916
|
className: "wgt-mark-face",
|
|
6880
6917
|
"data-mark": mark,
|
|
@@ -7678,7 +7715,7 @@ function DockSheet({ snap, onSnapChange, label, peekOnly, header, children, onDi
|
|
|
7678
7715
|
* `@wesence/agent-core`) rather than keeping a copy; that file's own doc
|
|
7679
7716
|
* comment carries the two 100x incidents that made the boundary worth naming.
|
|
7680
7717
|
*/
|
|
7681
|
-
var ZERO_DECIMAL_CURRENCIES = new Set([
|
|
7718
|
+
var ZERO_DECIMAL_CURRENCIES = /* @__PURE__ */ new Set([
|
|
7682
7719
|
"BIF",
|
|
7683
7720
|
"CLP",
|
|
7684
7721
|
"DJF",
|
|
@@ -7710,7 +7747,7 @@ var ZERO_DECIMAL_CURRENCIES = new Set([
|
|
|
7710
7747
|
* Gulf-relevant rather than theoretical: three of these seven (BHD, KWD, OMR)
|
|
7711
7748
|
* are GCC currencies.
|
|
7712
7749
|
*/
|
|
7713
|
-
var THREE_DECIMAL_CURRENCIES = new Set([
|
|
7750
|
+
var THREE_DECIMAL_CURRENCIES = /* @__PURE__ */ new Set([
|
|
7714
7751
|
"BHD",
|
|
7715
7752
|
"IQD",
|
|
7716
7753
|
"JOD",
|
|
@@ -8064,7 +8101,7 @@ var DOCK_STATES = CONCIERGE_STATES;
|
|
|
8064
8101
|
/** A dock nobody has touched, on a tenant with no voice — see `idleConciergeInput`. */
|
|
8065
8102
|
var idleDockInput = idleConciergeInput;
|
|
8066
8103
|
/** §1 rule 5 — the three states in which the audio channel is open. */
|
|
8067
|
-
var AUDIO_OPEN = new Set([
|
|
8104
|
+
var AUDIO_OPEN = /* @__PURE__ */ new Set([
|
|
8068
8105
|
"listening",
|
|
8069
8106
|
"thinking",
|
|
8070
8107
|
"speaking"
|
|
@@ -8391,11 +8428,11 @@ function BrandWordmark({ name }) {
|
|
|
8391
8428
|
}
|
|
8392
8429
|
//#endregion
|
|
8393
8430
|
//#region src/dock/dock.tsx
|
|
8394
|
-
var DEFAULT_COLOR = {
|
|
8431
|
+
var DEFAULT_COLOR$1 = {
|
|
8395
8432
|
primary: "#4c1d50",
|
|
8396
8433
|
tone: "light"
|
|
8397
8434
|
};
|
|
8398
|
-
var DEFAULT_TYPE = {
|
|
8435
|
+
var DEFAULT_TYPE$1 = {
|
|
8399
8436
|
font: "inherit",
|
|
8400
8437
|
radius: "soft",
|
|
8401
8438
|
caps: "none"
|
|
@@ -8407,7 +8444,7 @@ var DEFAULT_LAYOUT = {
|
|
|
8407
8444
|
};
|
|
8408
8445
|
var INTERRUPT_SEEN_STORAGE_KEY = "wgt_dock_interrupt_seen";
|
|
8409
8446
|
function Dock(props) {
|
|
8410
|
-
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;
|
|
8447
|
+
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;
|
|
8411
8448
|
const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
8412
8449
|
const rootRef = useRef(null);
|
|
8413
8450
|
const rowRef = useRef(null);
|
|
@@ -9295,15 +9332,9 @@ function Dock(props) {
|
|
|
9295
9332
|
* Emitted TWICE, against `:host` and against this instance's own scope
|
|
9296
9333
|
* attribute, because the dock renders in both worlds: inside `core.ts`'s
|
|
9297
9334
|
* shadow root for the CDN embed, and in LIGHT DOM for a Next.js host and
|
|
9298
|
-
* the marketing preview.
|
|
9299
|
-
* one invalid selector invalidates the whole rule — so they are two blocks
|
|
9300
|
-
* with identical bodies.
|
|
9335
|
+
* the marketing preview.
|
|
9301
9336
|
*/
|
|
9302
|
-
const themeCss = useMemo(() => {
|
|
9303
|
-
const theme = deriveTheme(color, type);
|
|
9304
|
-
const scope = `[data-wgt-scope="${scopeId}"]`;
|
|
9305
|
-
return `${themeToCss(theme, ":host")}\n${themeToCss(theme, scope)}\n${themeToMarkedHostCss(theme, scope)}`;
|
|
9306
|
-
}, [
|
|
9337
|
+
const themeCss = useMemo(() => scopedThemeCss(deriveTheme(color, type), `[data-wgt-scope="${scopeId}"]`, void 0, true), [
|
|
9307
9338
|
color,
|
|
9308
9339
|
type,
|
|
9309
9340
|
scopeId
|
|
@@ -10157,7 +10188,7 @@ function createLucideIcon(iconDataOrName, iconNode = [], aliases = []) {
|
|
|
10157
10188
|
* This source code is licensed under the ISC license.
|
|
10158
10189
|
* See the LICENSE file in the root directory of this source tree.
|
|
10159
10190
|
*/
|
|
10160
|
-
var __iconData$
|
|
10191
|
+
var __iconData$5 = {
|
|
10161
10192
|
name: "grip-vertical",
|
|
10162
10193
|
size: 24,
|
|
10163
10194
|
node: [
|
|
@@ -10199,8 +10230,8 @@ var __iconData$6 = {
|
|
|
10199
10230
|
}]
|
|
10200
10231
|
]
|
|
10201
10232
|
};
|
|
10202
|
-
__iconData$
|
|
10203
|
-
var GripVertical = createLucideIcon(__iconData$
|
|
10233
|
+
__iconData$5.node;
|
|
10234
|
+
var GripVertical = createLucideIcon(__iconData$5);
|
|
10204
10235
|
//#endregion
|
|
10205
10236
|
//#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
|
|
10206
10237
|
/**
|
|
@@ -10209,7 +10240,7 @@ var GripVertical = createLucideIcon(__iconData$6);
|
|
|
10209
10240
|
* This source code is licensed under the ISC license.
|
|
10210
10241
|
* See the LICENSE file in the root directory of this source tree.
|
|
10211
10242
|
*/
|
|
10212
|
-
var __iconData$
|
|
10243
|
+
var __iconData$4 = {
|
|
10213
10244
|
name: "mic-off",
|
|
10214
10245
|
size: 24,
|
|
10215
10246
|
node: [
|
|
@@ -10239,8 +10270,8 @@ var __iconData$5 = {
|
|
|
10239
10270
|
}]
|
|
10240
10271
|
]
|
|
10241
10272
|
};
|
|
10242
|
-
__iconData$
|
|
10243
|
-
var MicOff = createLucideIcon(__iconData$
|
|
10273
|
+
__iconData$4.node;
|
|
10274
|
+
var MicOff = createLucideIcon(__iconData$4);
|
|
10244
10275
|
//#endregion
|
|
10245
10276
|
//#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
|
|
10246
10277
|
/**
|
|
@@ -10249,7 +10280,7 @@ var MicOff = createLucideIcon(__iconData$5);
|
|
|
10249
10280
|
* This source code is licensed under the ISC license.
|
|
10250
10281
|
* See the LICENSE file in the root directory of this source tree.
|
|
10251
10282
|
*/
|
|
10252
|
-
var __iconData$
|
|
10283
|
+
var __iconData$3 = {
|
|
10253
10284
|
name: "mic",
|
|
10254
10285
|
size: 24,
|
|
10255
10286
|
node: [
|
|
@@ -10271,8 +10302,8 @@ var __iconData$4 = {
|
|
|
10271
10302
|
}]
|
|
10272
10303
|
]
|
|
10273
10304
|
};
|
|
10274
|
-
__iconData$
|
|
10275
|
-
var Mic = createLucideIcon(__iconData$
|
|
10305
|
+
__iconData$3.node;
|
|
10306
|
+
var Mic = createLucideIcon(__iconData$3);
|
|
10276
10307
|
//#endregion
|
|
10277
10308
|
//#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
|
|
10278
10309
|
/**
|
|
@@ -10281,7 +10312,7 @@ var Mic = createLucideIcon(__iconData$4);
|
|
|
10281
10312
|
* This source code is licensed under the ISC license.
|
|
10282
10313
|
* See the LICENSE file in the root directory of this source tree.
|
|
10283
10314
|
*/
|
|
10284
|
-
var __iconData$
|
|
10315
|
+
var __iconData$2 = {
|
|
10285
10316
|
name: "phone-off",
|
|
10286
10317
|
size: 24,
|
|
10287
10318
|
node: [
|
|
@@ -10299,8 +10330,8 @@ var __iconData$3 = {
|
|
|
10299
10330
|
}]
|
|
10300
10331
|
]
|
|
10301
10332
|
};
|
|
10302
|
-
__iconData$
|
|
10303
|
-
var PhoneOff = createLucideIcon(__iconData$
|
|
10333
|
+
__iconData$2.node;
|
|
10334
|
+
var PhoneOff = createLucideIcon(__iconData$2);
|
|
10304
10335
|
//#endregion
|
|
10305
10336
|
//#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
|
|
10306
10337
|
/**
|
|
@@ -10309,7 +10340,7 @@ var PhoneOff = createLucideIcon(__iconData$3);
|
|
|
10309
10340
|
* This source code is licensed under the ISC license.
|
|
10310
10341
|
* See the LICENSE file in the root directory of this source tree.
|
|
10311
10342
|
*/
|
|
10312
|
-
var __iconData$
|
|
10343
|
+
var __iconData$1 = {
|
|
10313
10344
|
name: "send",
|
|
10314
10345
|
size: 24,
|
|
10315
10346
|
node: [["path", {
|
|
@@ -10320,30 +10351,8 @@ var __iconData$2 = {
|
|
|
10320
10351
|
key: "12cjpa"
|
|
10321
10352
|
}]]
|
|
10322
10353
|
};
|
|
10323
|
-
__iconData$2.node;
|
|
10324
|
-
var Send = createLucideIcon(__iconData$2);
|
|
10325
|
-
//#endregion
|
|
10326
|
-
//#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
|
|
10327
|
-
/**
|
|
10328
|
-
* @license lucide-react v1.50.0 - ISC
|
|
10329
|
-
*
|
|
10330
|
-
* This source code is licensed under the ISC license.
|
|
10331
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
10332
|
-
*/
|
|
10333
|
-
var __iconData$1 = {
|
|
10334
|
-
name: "square",
|
|
10335
|
-
size: 24,
|
|
10336
|
-
node: [["rect", {
|
|
10337
|
-
width: "18",
|
|
10338
|
-
height: "18",
|
|
10339
|
-
x: "3",
|
|
10340
|
-
y: "3",
|
|
10341
|
-
rx: "2",
|
|
10342
|
-
key: "afitv7"
|
|
10343
|
-
}]]
|
|
10344
|
-
};
|
|
10345
10354
|
__iconData$1.node;
|
|
10346
|
-
var
|
|
10355
|
+
var Send = createLucideIcon(__iconData$1);
|
|
10347
10356
|
//#endregion
|
|
10348
10357
|
//#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
|
|
10349
10358
|
/**
|
|
@@ -10366,8 +10375,158 @@ var __iconData = {
|
|
|
10366
10375
|
__iconData.node;
|
|
10367
10376
|
var X = createLucideIcon(__iconData);
|
|
10368
10377
|
//#endregion
|
|
10378
|
+
//#region src/widget/mark-look.ts
|
|
10379
|
+
/**
|
|
10380
|
+
* The mark's static geometry and colours, shared by the React `Mark`
|
|
10381
|
+
* (`mark.tsx`) and the plain-DOM cold launcher (`cdn/launcher-dom.ts`).
|
|
10382
|
+
*
|
|
10383
|
+
* Framework-free on purpose: `launcher-dom.ts` ships in the `core` artefact,
|
|
10384
|
+
* which carries no React. Both renderers read the same declarations, so the
|
|
10385
|
+
* cold launcher and the React one cannot drift apart at the handover. They
|
|
10386
|
+
* are CSS declaration strings rather than style objects because `core` ships
|
|
10387
|
+
* unminified whitespace and a budget with a few hundred bytes of headroom: one
|
|
10388
|
+
* line of CSS per element costs a fraction of an object literal. React reads
|
|
10389
|
+
* them through `styleOf`. Animation lives in `styles/mark.css`, which only
|
|
10390
|
+
* the React stage loads.
|
|
10391
|
+
*/
|
|
10392
|
+
function isMarkVariant(value) {
|
|
10393
|
+
return typeof value === "string" && MARK_VARIANTS.includes(value);
|
|
10394
|
+
}
|
|
10395
|
+
/** Resting heights of the four bars, as a fraction of the bar box. */
|
|
10396
|
+
var MARK_BARS = [
|
|
10397
|
+
.5,
|
|
10398
|
+
.9,
|
|
10399
|
+
.65,
|
|
10400
|
+
.4
|
|
10401
|
+
];
|
|
10402
|
+
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))`;
|
|
10403
|
+
var markBarsCss = (size) => `display:flex;align-items:center;gap:${tenth(size * .055)}px;height:46%`;
|
|
10404
|
+
var markBarCss = (size, k) => `display:block;width:${Math.max(2, tenth(size * .07))}px;height:100%;border-radius:99px;background:currentColor;transform:scaleY(${k})`;
|
|
10405
|
+
var markMonoCss = (size) => `font-weight:600;font-size:${tenth(size * .44)}px;line-height:1;font-family:var(--wgt-font,inherit)`;
|
|
10406
|
+
var MARK_PIP_CSS = "width:30%;height:30%;border-radius:50%;background:currentColor";
|
|
10407
|
+
function tenth(n) {
|
|
10408
|
+
return Math.round(n * 10) / 10;
|
|
10409
|
+
}
|
|
10410
|
+
/** What the mark draws: a monogram with no letter falls back to bars. */
|
|
10411
|
+
function drawnMark(variant, name) {
|
|
10412
|
+
const letter = variant === "monogram" ? firstGrapheme(name) : "";
|
|
10413
|
+
return {
|
|
10414
|
+
drawn: variant === "monogram" && letter === "" ? "bars" : variant,
|
|
10415
|
+
letter
|
|
10416
|
+
};
|
|
10417
|
+
}
|
|
10418
|
+
/**
|
|
10419
|
+
* The monogram's letter: the first grapheme of the agent's name, uppercased.
|
|
10420
|
+
* A grapheme, not a code unit, so an accented or emoji-led name keeps its
|
|
10421
|
+
* first visible character whole. Empty name ⇒ `''`; callers then draw bars.
|
|
10422
|
+
*/
|
|
10423
|
+
function firstGrapheme(name) {
|
|
10424
|
+
const trimmed = name?.trim() ?? "";
|
|
10425
|
+
if (trimmed === "") return "";
|
|
10426
|
+
return ((Intl.Segmenter ? new Intl.Segmenter().segment(trimmed)[Symbol.iterator]().next().value?.segment : Array.from(trimmed)[0]) ?? "").toLocaleUpperCase();
|
|
10427
|
+
}
|
|
10428
|
+
//#endregion
|
|
10429
|
+
//#region src/widget/style-of.ts
|
|
10430
|
+
var cache = /* @__PURE__ */ new Map();
|
|
10431
|
+
/**
|
|
10432
|
+
* A CSS declaration string as a React style object — how the React launcher
|
|
10433
|
+
* and mark read the declarations they share with the cold launcher
|
|
10434
|
+
* (`launcher-look.ts`, `mark-look.ts`). Memoised: the strings are a handful of
|
|
10435
|
+
* constants, and a stable object is one React does not diff key by key.
|
|
10436
|
+
*/
|
|
10437
|
+
function styleOf(css) {
|
|
10438
|
+
let style = cache.get(css);
|
|
10439
|
+
if (style === void 0) {
|
|
10440
|
+
const out = {};
|
|
10441
|
+
for (const declaration of css.split(";")) {
|
|
10442
|
+
const colon = declaration.indexOf(":");
|
|
10443
|
+
if (colon < 0) continue;
|
|
10444
|
+
const name = declaration.slice(0, colon).trim();
|
|
10445
|
+
out[name.startsWith("--") ? name : name.replace(/-([a-z])/g, (_, c) => c.toUpperCase())] = declaration.slice(colon + 1).trim();
|
|
10446
|
+
}
|
|
10447
|
+
style = out;
|
|
10448
|
+
cache.set(css, style);
|
|
10449
|
+
}
|
|
10450
|
+
return style;
|
|
10451
|
+
}
|
|
10452
|
+
//#endregion
|
|
10453
|
+
//#region src/widget/mark.tsx
|
|
10454
|
+
/** Every state the mark draws. `muted` and `connecting` come from the voice session, not `BotState`. */
|
|
10455
|
+
var MARK_STATES = [
|
|
10456
|
+
"idle",
|
|
10457
|
+
"connecting",
|
|
10458
|
+
"listening",
|
|
10459
|
+
"thinking",
|
|
10460
|
+
"speaking",
|
|
10461
|
+
"muted"
|
|
10462
|
+
];
|
|
10463
|
+
/**
|
|
10464
|
+
* The mark's state from the session's. Muted wins over everything except
|
|
10465
|
+
* speaking: the agent can still talk while the shopper's mic is off.
|
|
10466
|
+
*/
|
|
10467
|
+
function markStateFor(state, flags = {}) {
|
|
10468
|
+
return flags.muted && state !== "speaking" ? "muted" : state;
|
|
10469
|
+
}
|
|
10470
|
+
/**
|
|
10471
|
+
* The simple brand mark: a flat disc in the tenant's primary with four bars,
|
|
10472
|
+
* a monogram, or a dot. Motion carries the state (`styles/mark.css`): bars
|
|
10473
|
+
* follow the voice while listening or speaking, a ring ripples while
|
|
10474
|
+
* listening, an arc orbits while thinking. Transform and opacity only, and
|
|
10475
|
+
* static under `prefers-reduced-motion`.
|
|
10476
|
+
*/
|
|
10477
|
+
function Mark({ variant, state = "idle", size, name, label, extraCss, testId }) {
|
|
10478
|
+
const { drawn, letter } = drawnMark(variant, name);
|
|
10479
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
10480
|
+
...label === void 0 ? { "aria-hidden": true } : {
|
|
10481
|
+
role: "img",
|
|
10482
|
+
"aria-label": label
|
|
10483
|
+
},
|
|
10484
|
+
className: "wmk",
|
|
10485
|
+
"data-mark": drawn,
|
|
10486
|
+
"data-mark-state": state,
|
|
10487
|
+
"data-testid": testId,
|
|
10488
|
+
style: styleOf(extraCss ? `${markRootCss(size)};${extraCss}` : markRootCss(size)),
|
|
10489
|
+
children: [
|
|
10490
|
+
state === "listening" ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { className: "wmk-r" }), /* @__PURE__ */ jsx("span", { className: "wmk-r" })] }) : null,
|
|
10491
|
+
drawn === "bars" ? /* @__PURE__ */ jsx("span", {
|
|
10492
|
+
className: "wmk-b",
|
|
10493
|
+
style: styleOf(markBarsCss(size)),
|
|
10494
|
+
children: MARK_BARS.map((k, i) => /* @__PURE__ */ jsx("i", {
|
|
10495
|
+
className: "wmk-i",
|
|
10496
|
+
style: styleOf(markBarCss(size, k))
|
|
10497
|
+
}, i))
|
|
10498
|
+
}) : drawn === "monogram" ? /* @__PURE__ */ jsx("span", {
|
|
10499
|
+
className: "wmk-m",
|
|
10500
|
+
style: styleOf(markMonoCss(size)),
|
|
10501
|
+
children: letter
|
|
10502
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
10503
|
+
className: "wmk-p",
|
|
10504
|
+
style: styleOf(MARK_PIP_CSS)
|
|
10505
|
+
}),
|
|
10506
|
+
state === "thinking" ? /* @__PURE__ */ jsx("svg", {
|
|
10507
|
+
className: "wmk-a",
|
|
10508
|
+
viewBox: "0 0 94 94",
|
|
10509
|
+
width: size + 18,
|
|
10510
|
+
height: size + 18,
|
|
10511
|
+
"aria-hidden": true,
|
|
10512
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
10513
|
+
cx: "47",
|
|
10514
|
+
cy: "47",
|
|
10515
|
+
r: "45",
|
|
10516
|
+
fill: "none"
|
|
10517
|
+
})
|
|
10518
|
+
}) : null
|
|
10519
|
+
]
|
|
10520
|
+
});
|
|
10521
|
+
}
|
|
10522
|
+
//#endregion
|
|
10369
10523
|
//#region src/avatar-face.tsx
|
|
10370
|
-
|
|
10524
|
+
/** Mark diameter per slot: the launcher's face box and the panel's hero. */
|
|
10525
|
+
var MARK_SIZE = {
|
|
10526
|
+
sm: 48,
|
|
10527
|
+
lg: 64
|
|
10528
|
+
};
|
|
10529
|
+
function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey, name, muted, markSize }) {
|
|
10371
10530
|
switch (avatar) {
|
|
10372
10531
|
case "orb": return /* @__PURE__ */ jsx(BotFace, {
|
|
10373
10532
|
state,
|
|
@@ -10381,10 +10540,60 @@ function AvatarFace({ avatar, state, size, label, messageArrived, tightenKey })
|
|
|
10381
10540
|
label,
|
|
10382
10541
|
tightenKey
|
|
10383
10542
|
});
|
|
10543
|
+
case "bars":
|
|
10544
|
+
case "monogram":
|
|
10545
|
+
case "dot": return /* @__PURE__ */ jsx(Mark, {
|
|
10546
|
+
variant: avatar,
|
|
10547
|
+
state: markStateFor(state, { muted }),
|
|
10548
|
+
size: markSize ?? MARK_SIZE[size],
|
|
10549
|
+
...name !== void 0 ? { name } : {},
|
|
10550
|
+
...label !== void 0 ? { label } : {}
|
|
10551
|
+
});
|
|
10384
10552
|
default: throw new Error(`Unhandled widget avatar: ${String(avatar)}`);
|
|
10385
10553
|
}
|
|
10386
10554
|
}
|
|
10387
10555
|
//#endregion
|
|
10556
|
+
//#region src/widget/launcher-look.ts
|
|
10557
|
+
/**
|
|
10558
|
+
* The collapsed launcher's look, shared by `concierge-launcher.tsx` (React)
|
|
10559
|
+
* and `cdn/launcher-dom.ts` (the plain-DOM cold twin `core` paints first).
|
|
10560
|
+
*
|
|
10561
|
+
* One set of declarations, two renderers: the handover from the cold pill to
|
|
10562
|
+
* React's must not visibly jump, and the cheapest way to keep two renderings
|
|
10563
|
+
* identical is to give them nothing to disagree about. Every value reads a
|
|
10564
|
+
* `--wgt-*` token with a literal fallback, because the cold launcher paints
|
|
10565
|
+
* before any stylesheet defining those tokens has been adopted. Strings, not
|
|
10566
|
+
* objects, for the reason `mark-look.ts` gives. Framework-free: ships in `core`.
|
|
10567
|
+
*/
|
|
10568
|
+
var LAUNCHER_VARIANTS = ["pill", "round"];
|
|
10569
|
+
var DEFAULT_LAUNCHER_VARIANT = "pill";
|
|
10570
|
+
/** Mark diameter inside each launcher. */
|
|
10571
|
+
var LAUNCHER_MARK_SIZE = {
|
|
10572
|
+
pill: 44,
|
|
10573
|
+
round: 60
|
|
10574
|
+
};
|
|
10575
|
+
var LAUNCHER_SURFACE = "var(--wgt-panel-surface,var(--widget-card,#fff))";
|
|
10576
|
+
var LAUNCHER_TEXT = "var(--wgt-text,var(--widget-foreground,#1c1618))";
|
|
10577
|
+
var MUTED = "var(--wgt-text-muted,var(--widget-foreground-muted,rgba(28,22,24,.73)))";
|
|
10578
|
+
var LAUNCHER_ELEVATION = "var(--wgt-elevation,0 0 0 1px rgba(0,0,0,.06),0 24px 60px -22px rgba(0,0,0,.32))";
|
|
10579
|
+
/** The live-call dot, and `--wgt-live`'s value: constant, so it reads as "live" on every theme. */
|
|
10580
|
+
var LIVE_COLOR = "#E5484D";
|
|
10581
|
+
var RADIUS = "var(--wgt-launcher-radius,999px)";
|
|
10582
|
+
/** The fixed root, before the anchor. */
|
|
10583
|
+
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` : "");
|
|
10584
|
+
/** The open control: mark + text in the pill, the mark alone in the round. */
|
|
10585
|
+
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%");
|
|
10586
|
+
/** The round launcher's mark carries the elevation; the pill's sits on a surface. */
|
|
10587
|
+
var ROUND_MARK_CSS = `box-shadow:${LAUNCHER_ELEVATION}`;
|
|
10588
|
+
var LAUNCHER_TEXT_CSS = `display:block;min-width:0;color:${LAUNCHER_TEXT}`;
|
|
10589
|
+
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}`;
|
|
10590
|
+
var LAUNCHER_SUB_CSS = `display:block;white-space:nowrap;font-size:12px;line-height:1.3;color:${MUTED};font-variant-numeric:tabular-nums`;
|
|
10591
|
+
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`;
|
|
10592
|
+
/** In the round launcher the grip is a small disc on the circle's lower start edge. */
|
|
10593
|
+
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}`;
|
|
10594
|
+
/** The grip's hit area: 44px across around the 28px grip, which keeps its look. */
|
|
10595
|
+
var GRIP_HIT_CSS = "position:absolute;inset:-8px";
|
|
10596
|
+
//#endregion
|
|
10388
10597
|
//#region src/widget/position.ts
|
|
10389
10598
|
/**
|
|
10390
10599
|
* Where the concierge sits on the host page, and how a visitor moves it.
|
|
@@ -10490,7 +10699,7 @@ var QUIET = {
|
|
|
10490
10699
|
badge: false,
|
|
10491
10700
|
initials: false
|
|
10492
10701
|
};
|
|
10493
|
-
function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "" }) {
|
|
10702
|
+
function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "", launcher = DEFAULT_LAUNCHER_VARIANT, agentName, subLabel, callLabel }) {
|
|
10494
10703
|
const rootRef = useRef(null);
|
|
10495
10704
|
/** Pixel offset while a drag is in flight; `null` when it is not. */
|
|
10496
10705
|
const [drag, setDrag] = useState(null);
|
|
@@ -10574,15 +10783,24 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10574
10783
|
if (next !== position) onPositionChange(next);
|
|
10575
10784
|
};
|
|
10576
10785
|
const dragging = drag !== null;
|
|
10786
|
+
const markSize = LAUNCHER_MARK_SIZE[launcher];
|
|
10787
|
+
const round = launcher === "round";
|
|
10788
|
+
const sub = callLabel ?? subLabel;
|
|
10789
|
+
const showText = !round && (label !== void 0 || sub !== void 0);
|
|
10790
|
+
const ariaLabel = round || label === void 0 ? [srLabel, callLabel].filter(Boolean).join(" · ") : void 0;
|
|
10577
10791
|
return /* @__PURE__ */ jsxs("div", {
|
|
10578
10792
|
ref: rootRef,
|
|
10579
10793
|
id,
|
|
10580
10794
|
"data-testid": testId,
|
|
10581
10795
|
"data-position": position,
|
|
10796
|
+
"data-launcher": launcher,
|
|
10582
10797
|
"aria-hidden": hidden,
|
|
10583
|
-
className: cn("fixed z-50
|
|
10584
|
-
style:
|
|
10585
|
-
|
|
10798
|
+
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),
|
|
10799
|
+
style: {
|
|
10800
|
+
...styleOf(launcherRootCss(launcher)),
|
|
10801
|
+
...drag ? { transform: `translate(${drag.dx}px, ${drag.dy}px)` } : {}
|
|
10802
|
+
},
|
|
10803
|
+
children: [onPositionChange ? /* @__PURE__ */ jsxs("button", {
|
|
10586
10804
|
type: "button",
|
|
10587
10805
|
"aria-label": moveLabel,
|
|
10588
10806
|
title: moveLabel,
|
|
@@ -10593,14 +10811,21 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10593
10811
|
onPointerUp,
|
|
10594
10812
|
onPointerCancel: onPointerUp,
|
|
10595
10813
|
onKeyDown: onGripKeyDown,
|
|
10596
|
-
className:
|
|
10597
|
-
|
|
10814
|
+
className: FOCUS_RING,
|
|
10815
|
+
style: {
|
|
10816
|
+
...styleOf(round ? `${LAUNCHER_GRIP_CSS};${ROUND_GRIP_CSS}` : LAUNCHER_GRIP_CSS),
|
|
10817
|
+
cursor: dragging ? "grabbing" : "grab"
|
|
10818
|
+
},
|
|
10819
|
+
children: [/* @__PURE__ */ jsx(GripVertical, {
|
|
10598
10820
|
className: "size-4",
|
|
10599
10821
|
"aria-hidden": true
|
|
10600
|
-
})
|
|
10822
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
10823
|
+
"aria-hidden": true,
|
|
10824
|
+
style: styleOf(GRIP_HIT_CSS)
|
|
10825
|
+
})]
|
|
10601
10826
|
}) : null, /* @__PURE__ */ jsxs("button", {
|
|
10602
10827
|
type: "button",
|
|
10603
|
-
"aria-label":
|
|
10828
|
+
"aria-label": ariaLabel,
|
|
10604
10829
|
tabIndex: hidden || spec.disabled ? -1 : 0,
|
|
10605
10830
|
disabled: spec.disabled,
|
|
10606
10831
|
...spec.busy ? { "aria-busy": true } : {},
|
|
@@ -10611,17 +10836,29 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10611
10836
|
onOpen();
|
|
10612
10837
|
},
|
|
10613
10838
|
"data-testid": testId ? `${testId}-open` : void 0,
|
|
10614
|
-
className:
|
|
10839
|
+
className: FOCUS_RING,
|
|
10840
|
+
style: styleOf(launcherOpenCss(launcher)),
|
|
10615
10841
|
children: [/* @__PURE__ */ jsxs("span", {
|
|
10616
10842
|
"aria-hidden": true,
|
|
10617
|
-
className: "relative block
|
|
10843
|
+
className: "relative block shrink-0",
|
|
10844
|
+
style: {
|
|
10845
|
+
width: markSize,
|
|
10846
|
+
height: markSize
|
|
10847
|
+
},
|
|
10618
10848
|
children: [
|
|
10619
10849
|
spec.initials && initials !== "" ? /* @__PURE__ */ jsx("span", {
|
|
10620
10850
|
"data-testid": "widget-launcher-initials",
|
|
10621
|
-
|
|
10851
|
+
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)`),
|
|
10622
10852
|
children: initials
|
|
10853
|
+
}) : isMarkVariant(avatar) ? /* @__PURE__ */ jsx(Mark, {
|
|
10854
|
+
variant: avatar,
|
|
10855
|
+
state: spec.busy ? "connecting" : "idle",
|
|
10856
|
+
size: markSize,
|
|
10857
|
+
...agentName !== void 0 ? { name: agentName } : {},
|
|
10858
|
+
...round ? { extraCss: ROUND_MARK_CSS } : {}
|
|
10623
10859
|
}) : /* @__PURE__ */ jsx("span", {
|
|
10624
|
-
className: "absolute start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2
|
|
10860
|
+
className: "absolute start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 rtl:translate-x-1/2",
|
|
10861
|
+
style: { scale: String(markSize / 64) },
|
|
10625
10862
|
children: /* @__PURE__ */ jsx(AvatarFace, {
|
|
10626
10863
|
avatar,
|
|
10627
10864
|
state: "idle",
|
|
@@ -10631,474 +10868,893 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10631
10868
|
}),
|
|
10632
10869
|
spec.busy ? /* @__PURE__ */ jsx("span", {
|
|
10633
10870
|
"data-testid": "widget-launcher-busy",
|
|
10634
|
-
className: "pointer-events-none absolute inset-
|
|
10871
|
+
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"
|
|
10635
10872
|
}) : null,
|
|
10636
10873
|
spec.badge ? /* @__PURE__ */ jsx("span", {
|
|
10637
10874
|
"data-testid": "widget-launcher-badge",
|
|
10638
|
-
|
|
10875
|
+
style: BADGE_STYLE
|
|
10876
|
+
}) : null,
|
|
10877
|
+
round && callLabel !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
10878
|
+
"data-testid": "widget-launcher-live",
|
|
10879
|
+
title: callLabel,
|
|
10880
|
+
style: LIVE_STYLE
|
|
10639
10881
|
}) : null
|
|
10640
10882
|
]
|
|
10641
|
-
}),
|
|
10883
|
+
}), showText ? /* @__PURE__ */ jsxs("span", {
|
|
10642
10884
|
dir: "auto",
|
|
10643
|
-
|
|
10644
|
-
children: label
|
|
10645
|
-
|
|
10885
|
+
style: styleOf(LAUNCHER_TEXT_CSS),
|
|
10886
|
+
children: [label !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
10887
|
+
style: styleOf(LAUNCHER_TITLE_CSS),
|
|
10888
|
+
children: label
|
|
10889
|
+
}) : null, sub !== void 0 ? /* @__PURE__ */ jsx("span", {
|
|
10890
|
+
"data-testid": "widget-launcher-sub",
|
|
10891
|
+
style: styleOf(LAUNCHER_SUB_CSS),
|
|
10892
|
+
children: sub
|
|
10893
|
+
}) : null]
|
|
10894
|
+
}) : null]
|
|
10646
10895
|
})]
|
|
10647
10896
|
});
|
|
10648
10897
|
}
|
|
10898
|
+
/** Something landed behind the closed panel. Text-coloured, so it reads on any brand mark. */
|
|
10899
|
+
var BADGE_STYLE = {
|
|
10900
|
+
position: "absolute",
|
|
10901
|
+
top: 0,
|
|
10902
|
+
insetInlineEnd: 0,
|
|
10903
|
+
width: 12,
|
|
10904
|
+
height: 12,
|
|
10905
|
+
borderRadius: "50%",
|
|
10906
|
+
background: LAUNCHER_TEXT,
|
|
10907
|
+
boxShadow: `0 0 0 2px ${LAUNCHER_SURFACE}`
|
|
10908
|
+
};
|
|
10909
|
+
/** A call is live (round launcher). */
|
|
10910
|
+
var LIVE_STYLE = {
|
|
10911
|
+
position: "absolute",
|
|
10912
|
+
top: 2,
|
|
10913
|
+
insetInlineStart: 2,
|
|
10914
|
+
width: 14,
|
|
10915
|
+
height: 14,
|
|
10916
|
+
borderRadius: "50%",
|
|
10917
|
+
background: `var(--wgt-live,${LIVE_COLOR})`,
|
|
10918
|
+
boxShadow: `0 0 0 2px ${LAUNCHER_SURFACE}`
|
|
10919
|
+
};
|
|
10920
|
+
var FOCUS_RING = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--wgt-ring,#111827)]";
|
|
10649
10921
|
//#endregion
|
|
10650
|
-
//#region
|
|
10651
|
-
/**
|
|
10652
|
-
* PANEL GEOMETRY — where the conversation's first row sits, as a FRACTION of
|
|
10653
|
-
* the panel's height, and what that costs horizontally.
|
|
10654
|
-
*
|
|
10655
|
-
* Four CSS length expressions and the arithmetic behind them, used by
|
|
10656
|
-
* `concierge-shell.tsx`'s `transcriptEdgeFade`. Their own module, and NOT
|
|
10657
|
-
* re-exported from `index.ts`: `concierge-shell.geometry.test.tsx` has to read
|
|
10658
|
-
* the exact strings the component ships (jsdom's CSS serializer mangles a
|
|
10659
|
-
* `max()` containing a subtraction, so reading them back off a rendered element
|
|
10660
|
-
* tests jsdom rather than this widget), while the package's public API stays
|
|
10661
|
-
* the components themselves.
|
|
10662
|
-
*
|
|
10663
|
-
* One ratio ties the four lengths together, and it is the whole
|
|
10664
|
-
* repair for a bug that shipped: the panel is an ellipse (`rounded-full` on a
|
|
10665
|
-
* `w x 1.6w` box), so how much width it offers depends entirely on how far down
|
|
10666
|
-
* you are. The clearances below scaled with `cqh` while the transcript's
|
|
10667
|
-
* horizontal inset was a fixed 8px tuned for the oval's wide middle, so the
|
|
10668
|
-
* taller the panel got the HIGHER the first message sat proportionally — into a
|
|
10669
|
-
* narrower part of the curve, with no matching inset. Measured live in
|
|
10670
|
-
* Storybook, first agent bubble's top-left corner against the curve at its own
|
|
10671
|
-
* top edge: 14px inside the ellipse at a 582px panel, 37px at 720px, 62px at
|
|
10672
|
-
* 920px (the 2000x1150 desktop it was reported on). `overflow-clip` on the
|
|
10673
|
-
* surface then cut exactly that much off the bubble.
|
|
10674
|
-
*
|
|
10675
|
-
* 0.1924 is not chosen, it is READ OFF the short panel: 112px (the tuned
|
|
10676
|
-
* clearance, see {@link TRANSCRIPT_FADE_TOP_LEN}) over 582px (the panel a
|
|
10677
|
-
* 375x812 phone renders) is 0.19244. Holding that ratio at every size is what
|
|
10678
|
-
* makes the geometry scale-invariant — every panel then presents the first row
|
|
10679
|
-
* at the same point on the same curve, and ONE horizontal inset serves all of
|
|
10680
|
-
* them ({@link TRANSCRIPT_INSET_X}). Expressed as `19.24cqh` in the lengths
|
|
10681
|
-
* below; `cqh` is the panel's own height, via `[container-type:size]` on the
|
|
10682
|
-
* panel div (verified live: `14cqh` resolved to 128.8px on a 920px panel).
|
|
10683
|
-
*
|
|
10684
|
-
* Not a JS constant that gets multiplied out — the panel's height is never
|
|
10685
|
-
* known to JS, only to CSS, which is why every length here is an expression.
|
|
10686
|
-
*/
|
|
10687
|
-
/**
|
|
10688
|
-
* Top ramp when the transcript starts at the panel's top, under the floating
|
|
10689
|
-
* orb — it has to span the orb, so a message is gone before it reaches it
|
|
10690
|
-
* rather than sliding out from behind it half-visible.
|
|
10691
|
-
*
|
|
10692
|
-
* A CSS length EXPRESSION, not a bare number, since the aspect-ratio panel
|
|
10693
|
-
* (`w-[min(97vw,50dvh)]` + `aspect-[5/8]`) ranges from ~582px tall (mobile,
|
|
10694
|
-
* width-bound) to 800px+ (desktop, height-bound) — a fixed 112px clearance
|
|
10695
|
-
* tuned for the OLD fixed-520px panel left too little air under the orb on a
|
|
10696
|
-
* tall one and too much on a short one. `max(112px, 19.24cqh)` is a floor, not
|
|
10697
|
-
* a fixed value: it stays exactly 112px (today's tuned figure) on a short
|
|
10698
|
-
* panel, where 19.24cqh would fall below it, and grows with `cqh` — the query
|
|
10699
|
-
* container's own height, established by `[container-type:size]` on the
|
|
10700
|
-
* panel div below — once the panel is tall enough that 19.24% of it exceeds
|
|
10701
|
-
* 112px. `cqh` rather than `dvh` specifically: the panel's real rendered
|
|
10702
|
-
* height, not the viewport's, since the panel does not always fill the
|
|
10703
|
-
* viewport (mobile: width-bound, height is `w / (8/5)`, shorter than 100dvh).
|
|
10704
|
-
*
|
|
10705
|
-
* 19.24, not the 14 this shipped with: 14cqh gave a TALL panel proportionally
|
|
10706
|
-
* LESS clearance than the 112px floor gives a short one (14% against 19.24%),
|
|
10707
|
-
* which pushed the first message up into the narrowing part of the ellipse —
|
|
10708
|
-
* see the ratio's own note above for the measurements. The floor and the
|
|
10709
|
-
* scaling term now agree at 582px (19.24% of 582 = 111.98), so the two meet
|
|
10710
|
-
* without a step rather than crossing over at some unrelated height.
|
|
10711
|
-
*/
|
|
10712
|
-
var TRANSCRIPT_FADE_TOP_LEN = "max(112px, 19.24cqh)";
|
|
10713
|
-
/**
|
|
10714
|
-
* Top ramp when a `badge` sits above the transcript.
|
|
10715
|
-
*
|
|
10716
|
-
* A badge has ALREADY pushed the transcript clear of the orb, so reusing the
|
|
10717
|
-
* orb-sized ramp charges for the same clearance twice: it left a 112px dead
|
|
10718
|
-
* band directly under the badge and dissolved the opening message for no
|
|
10719
|
-
* reason (measured in `WithABadgeAndNoVoice` — orb ends 565, badge 573-598,
|
|
10720
|
-
* first message could not start above 710). At that point the fade is only
|
|
10721
|
-
* doing its ordinary job of softening a scroll edge, so it wants an ordinary
|
|
10722
|
-
* scroll-edge length. Same floor+`cqh` scheme as {@link TRANSCRIPT_FADE_TOP_LEN}
|
|
10723
|
-
* above and for the same reason — this ramp needs to soften proportionally
|
|
10724
|
-
* more of a tall panel's scroll edge than a short one's.
|
|
10725
|
-
*
|
|
10726
|
-
* The third arm is the ellipse, and it is what keeps this variant honest at
|
|
10727
|
-
* sizes the badge's own fixed offsets stop covering. With a badge the first row
|
|
10728
|
-
* is pushed down by chrome that does NOT scale — 1px surface border + 6px
|
|
10729
|
-
* column padding + the badge wrapper's `mt-[104px]` + 4px list padding = 115px
|
|
10730
|
-
* — so the row lands at `(115px + this ramp) / panelHeight`, a fraction that
|
|
10731
|
-
* SHRINKS as the panel grows. `19.24cqh - 115px` is that equation solved for
|
|
10732
|
-
* the ramp, so the row lands on the same point of the curve the no-badge
|
|
10733
|
-
* variant does. It is inert on the panels this variant was tuned against
|
|
10734
|
-
* (negative at 582px, 4.5px at 720px, so the other two arms win) and takes over
|
|
10735
|
-
* only above ~745px, where the fixed 115px has stopped being enough.
|
|
10736
|
-
*
|
|
10737
|
-
* The badge's own height is counted as ZERO in that 115px, deliberately:
|
|
10738
|
-
* `badge` is an arbitrary node from the host (`voice-widget.tsx` passes a
|
|
10739
|
-
* one-line status pill, ~26px), and only the shortest-badge bound holds for
|
|
10740
|
-
* every caller. A taller badge pushes the row further down, which is the safe
|
|
10741
|
-
* direction.
|
|
10742
|
-
*/
|
|
10743
|
-
var TRANSCRIPT_FADE_TOP_WITH_BADGE_LEN = "max(28px, 4cqh, 19.24cqh - 115px)";
|
|
10744
|
-
var TRANSCRIPT_FADE_BOTTOM_LEN = "max(136px, 23.36cqh)";
|
|
10745
|
-
/**
|
|
10746
|
-
* The transcript's horizontal inset — the width the ellipse actually costs.
|
|
10747
|
-
*
|
|
10748
|
-
* `10.6cqw` is where the curve is at the first row's height: on an ellipse of
|
|
10749
|
-
* width `w`, at the fraction 0.1924 of the way down (the ratio the clearances
|
|
10750
|
-
* above hold at every size), the left edge lies `w * (1 - sqrt(1 - (2*0.1924 -
|
|
10751
|
-
* 1)^2)) / 2` = `0.1058 * w` in from the bounding box. Rounded up to 10.6% so
|
|
10752
|
-
* the rounding goes toward clearance rather than away from it.
|
|
10753
|
-
*
|
|
10754
|
-
* `- 11px` because 11px of that is already paid for by fixed chrome outside
|
|
10755
|
-
* this element: the surface's 1px border plus the inner column's `px-2.5`. The
|
|
10756
|
-
* inset is measured from the PANEL's box, which is where the curve is; this
|
|
10757
|
-
* padding only has to make up the difference. Verified live: a 363.8px-wide
|
|
10758
|
-
* panel put the first bubble's left edge at 19px = 11px chrome + the 8px this
|
|
10759
|
-
* replaces.
|
|
10760
|
-
*
|
|
10761
|
-
* The `8px` floor is the value this shipped with, kept as a lower bound so a
|
|
10762
|
-
* degenerately small panel can never end up with less padding than a plain
|
|
10763
|
-
* scroll edge wants. It is inert at every real size (the formula gives 27.6px
|
|
10764
|
-
* on the smallest panel the widget renders).
|
|
10765
|
-
*
|
|
10766
|
-
* Symmetric on purpose, and applied as `padding-inline` so it stays symmetric
|
|
10767
|
-
* in RTL: the ellipse is symmetric, the visitor's own bubbles are `justify-end`
|
|
10768
|
-
* against the other side of it, and either side is the first row's side
|
|
10769
|
-
* depending on who spoke.
|
|
10770
|
-
*/
|
|
10771
|
-
var TRANSCRIPT_INSET_X = "max(8px, 10.6cqw - 11px)";
|
|
10772
|
-
/**
|
|
10773
|
-
* The composer overlay's bottom offset when the microphone is drawn.
|
|
10774
|
-
*
|
|
10775
|
-
* `11.86cqh` is {@link COMPOSER_ROW_FRACTION} as a length. `- 63px` is
|
|
10776
|
-
* everything between this offset and the input's bottom edge that does NOT
|
|
10777
|
-
* scale: the surface's 1px border (the overlay is positioned against the inner
|
|
10778
|
-
* column's padding box, one border inside the panel) plus the 62px microphone
|
|
10779
|
-
* block — a 10px `gap-2.5`, the row's 4px `mt-1`, and a 48px `size-12` button.
|
|
10780
|
-
*
|
|
10781
|
-
* `max(6px, …)` keeps the 6px this shipped with as a floor, and the two arms
|
|
10782
|
-
* MEET at the panel it was tuned on rather than crossing somewhere unrelated:
|
|
10783
|
-
* `11.86cqh - 63px` is 6.03px at 582px, so a phone renders what it rendered
|
|
10784
|
-
* before to a hundredth of a pixel and only larger panels lift the composer.
|
|
10785
|
-
*/
|
|
10786
|
-
var COMPOSER_BOTTOM_LEN = "max(6px, 15cqh - 63px)";
|
|
10787
|
-
/**
|
|
10788
|
-
* The composer overlay's bottom offset when there is NO microphone.
|
|
10789
|
-
*
|
|
10790
|
-
* Same target row, minus only the 1px surface border: with `voice` omitted the
|
|
10791
|
-
* overlay's last child IS the input, so the 62px the microphone block
|
|
10792
|
-
* contributed above has to come from this offset instead. That is a real move —
|
|
10793
|
-
* 6px to 68px on a phone — and it is the fix rather than a side effect. Left at
|
|
10794
|
-
* 6px the input sits 7px off a `rounded-full` panel's bottom tip, where the
|
|
10795
|
-
* ellipse offers 79px of width in total; no width cap can rescue that row, so
|
|
10796
|
-
* the row itself has to come up to where the panel is wide enough to hold it.
|
|
10797
|
-
*
|
|
10798
|
-
* The band it moves into is the one the microphone would have occupied, which
|
|
10799
|
-
* the transcript already clears ({@link TRANSCRIPT_FADE_BOTTOM_LEN} is sized
|
|
10800
|
-
* for the input + microphone pair regardless of whether the pair is drawn), so
|
|
10801
|
-
* nothing above has to move to make room.
|
|
10802
|
-
*/
|
|
10803
|
-
var COMPOSER_BOTTOM_NO_VOICE_LEN = "max(6px, 15cqh - 1px)";
|
|
10804
|
-
/**
|
|
10805
|
-
* The composer's width cap — what the ellipse actually offers at that row.
|
|
10806
|
-
*
|
|
10807
|
-
* On an ellipse of width `w`, at the fraction `1 - 0.1186` of the way down, the
|
|
10808
|
-
* full chord is `w * sqrt(1 - (2*0.8814 - 1)^2)` = `0.6465 * w`. So `64.65cqw`
|
|
10809
|
-
* is not a taste-tuned percentage, it is the panel's own width at the row the
|
|
10810
|
-
* two offsets above pin the input to — where `w-[71%]`, the class this caps,
|
|
10811
|
-
* was 6.4% of the panel too wide at EVERY size (10.8px of overhang on a phone,
|
|
10812
|
-
* 52.0px on a 920px panel, because the row also drifts lower as the panel
|
|
10813
|
-
* grows).
|
|
10814
|
-
*
|
|
10815
|
-
* `- 10px` is clearance, 5px each side, matching the 5px the transcript's rows
|
|
10816
|
-
* clear the curve by — the panel paints a 1.5px gradient ring plus a 1px
|
|
10817
|
-
* surface border at that edge, and the input's own rounding means the arc, not
|
|
10818
|
-
* the corner, is what approaches the curve.
|
|
10819
|
-
*
|
|
10820
|
-
* Applied as `max-width` over the existing `w-[71%]`, not in place of it: 71%
|
|
10821
|
-
* stays the upper bound the composer had, and this only ever tightens it (the
|
|
10822
|
-
* ellipse term is below 71% for any panel, since 0.6465 < 0.71). The `160px`
|
|
10823
|
-
* floor is the "cap it sensibly" arm — it stops a degenerately small panel from
|
|
10824
|
-
* resolving the composer to a few dozen pixels of unusable input, and it is
|
|
10825
|
-
* inert at every size the widget really renders (it binds only below a 248px
|
|
10826
|
-
* panel; the narrowest phone in circulation, 320px, gives 310px).
|
|
10827
|
-
*/
|
|
10828
|
-
var COMPOSER_MAX_WIDTH_LEN = "max(160px, 71.41cqw - 10px)";
|
|
10829
|
-
/**
|
|
10830
|
-
* The opaque ground the composer sits on, which has to keep covering it.
|
|
10831
|
-
*
|
|
10832
|
-
* The transcript runs the panel's whole height and passes BEHIND this row, so
|
|
10833
|
-
* this gradient is the only thing between a message and the input's own
|
|
10834
|
-
* translucent chip fill. It was a fixed `h-[132px]`, tuned when the composer
|
|
10835
|
-
* was pinned 6px off the bottom on every panel — and the moment the offsets
|
|
10836
|
-
* above start lifting the composer on a tall panel, a fixed ground stops
|
|
10837
|
-
* reaching its top edge (the composer's top is `11.86cqh + 40px` above the
|
|
10838
|
-
* panel's bottom: 109px at 582px, but 149px at 920px, against 132px of ground).
|
|
10839
|
-
*
|
|
10840
|
-
* 22.68cqh is the same read-off-the-short-panel derivation as everything else
|
|
10841
|
-
* here — 132/582 = 0.22680 — so a phone renders exactly the 132px it rendered
|
|
10842
|
-
* before and the ground grows with the row it is under. It stays above the
|
|
10843
|
-
* composer's own top at every size, and stays the same shade taller than the
|
|
10844
|
-
* transcript's bottom clearance that it is today ({@link
|
|
10845
|
-
* TRANSCRIPT_FADE_BOTTOM_LEN} is 20.27cqh against this 22.68cqh, exactly the
|
|
10846
|
-
* 118:132 relationship the two were tuned at), so they still meet without a
|
|
10847
|
-
* seam or a band of doubly-darkened panel.
|
|
10848
|
-
*/
|
|
10849
|
-
var COMPOSER_GROUND_LEN = "max(150px, 25.77cqh)";
|
|
10850
|
-
//#endregion
|
|
10851
|
-
//#region src/widget/concierge-shell.tsx
|
|
10922
|
+
//#region ../widget-protocol/dist/text-direction.js
|
|
10852
10923
|
/**
|
|
10853
|
-
*
|
|
10924
|
+
* Base direction for a block of text whose language is the CONTENT's, not the
|
|
10925
|
+
* reader's. Pure, string-only and dependency-free: a STATIC import into the
|
|
10926
|
+
* chat bundle a shopper downloads, shared by the console (`apps/web`) and the
|
|
10927
|
+
* widget (`@saar-ai/web-widget`), which used to keep a hand copy each.
|
|
10854
10928
|
*
|
|
10855
|
-
*
|
|
10856
|
-
*
|
|
10857
|
-
*
|
|
10858
|
-
*
|
|
10929
|
+
* It lives here rather than in `@wesence/i18n` because the widget's published
|
|
10930
|
+
* bundle may resolve no `@wesence/*` module at all (`docs/PACKAGE_DISTRIBUTION.md`,
|
|
10931
|
+
* enforced by `scripts/check-npm-bundle-provenance.mjs`), the same reason
|
|
10932
|
+
* `./money` lives here.
|
|
10933
|
+
*
|
|
10934
|
+
* ## Why the console's own direction is the wrong answer
|
|
10935
|
+
*
|
|
10936
|
+
* `<html dir>` is set from the operator's UI locale, and every element inherits
|
|
10937
|
+
* it. That is right for the chrome and wrong for a transcript: an
|
|
10938
|
+
* English-speaking agent reading an Arabic conversation would render each
|
|
10939
|
+
* message with an LTR base direction, and the Unicode bidirectional algorithm
|
|
10940
|
+
* would then lay out the runs in the wrong order and throw trailing punctuation
|
|
10941
|
+
* to the wrong end of the line.
|
|
10942
|
+
*
|
|
10943
|
+
* The failure is invisible to the person looking at it. An agent who cannot read
|
|
10944
|
+
* Arabic sees Arabic-looking text and moves on; the customer is the one who gets
|
|
10945
|
+
* quoted back a sentence that reads incorrectly. The reverse case is just as
|
|
10946
|
+
* real — an Arabic-speaking agent reading English conversations under an RTL
|
|
10947
|
+
* base.
|
|
10948
|
+
*
|
|
10949
|
+
* ## Mixed runs are the normal case here, not an edge case
|
|
10950
|
+
*
|
|
10951
|
+
* Verified against live recognition output: Arabic comes back as
|
|
10952
|
+
* `رقم الـ order هو 4471. Please check من فضلك.` and Hindi as
|
|
10953
|
+
* `मेरा order number 4471 है।`. Latin nouns inside a non-Latin sentence are what
|
|
10954
|
+
* this product's transcripts actually contain, so bidirectional layout is
|
|
10955
|
+
* exercised on ordinary traffic rather than by an unusual customer.
|
|
10956
|
+
*
|
|
10957
|
+
* ## `auto` is the floor, not the goal
|
|
10958
|
+
*
|
|
10959
|
+
* With a known language this returns a definite direction. Without one it
|
|
10960
|
+
* returns `auto`, which delegates to the browser's first-strong-character
|
|
10961
|
+
* heuristic — better than inheriting the chrome, but wrong for a message that
|
|
10962
|
+
* opens with an English word and continues in Arabic (`Please check من فضلك`).
|
|
10963
|
+
* The real fix is to persist the conversation's resolved locale and pass it in;
|
|
10964
|
+
* see the note in `Transcript`.
|
|
10859
10965
|
*/
|
|
10860
|
-
var FOLLOW_TOLERANCE_PX = 24;
|
|
10861
|
-
/**
|
|
10862
|
-
* Build the transcript's mask + the padding that matches it.
|
|
10863
|
-
*
|
|
10864
|
-
* The two must be derived together: the padding is what lets the first and
|
|
10865
|
-
* last messages scroll clear of the ramp, so a ramp length that is not also
|
|
10866
|
-
* the padding leaves the newest message permanently half-dissolved.
|
|
10867
|
-
*
|
|
10868
|
-
* The top half of the top ramp is fully transparent (SAA-435): text beside
|
|
10869
|
-
* the orb read through at 20-45% under the old eased ramp, which looked like
|
|
10870
|
-
* no fade at all. It now clears completely before it reaches the orb's row.
|
|
10871
|
-
*
|
|
10872
|
-
* The top ramp's stops are scaled from `topLen` rather than hardcoded, so the
|
|
10873
|
-
* shortened badge variant keeps the same eased shape instead of becoming a
|
|
10874
|
-
* steep two-point cut. `topLen` is a CSS length EXPRESSION now (a `max(<px>,
|
|
10875
|
-
* <N>cqh)` floor, see the constants above), not a plain number — `at(fraction)`
|
|
10876
|
-
* therefore emits `calc(<topLen> * <fraction>)` rather than doing the
|
|
10877
|
-
* multiplication in JS, so each stop scales with the query container's
|
|
10878
|
-
* height (`cqh`) exactly the way `topLen` itself does. `calc()` accepts a
|
|
10879
|
-
* `max()` expression as its left operand (`max()` resolves to a `<length>`,
|
|
10880
|
-
* and a `<length>` may be multiplied by a bare `<number>` inside `calc()`),
|
|
10881
|
-
* so this composes without a second unit-handling special case.
|
|
10882
|
-
*
|
|
10883
|
-
* The bottom ramp's own inner taper (the last four stops, `96px`/`72px`/
|
|
10884
|
-
* `48px`/`24px`) stays fixed pixels, deliberately NOT scaled by `cqh`: it is
|
|
10885
|
-
* a small, fixed-shape cosmetic fade against the very bottom edge, sized
|
|
10886
|
-
* once and unrelated to how much CLEARANCE the composer needs above it —
|
|
10887
|
-
* that clearance is what `TRANSCRIPT_FADE_BOTTOM_LEN` (the transition point
|
|
10888
|
-
* this taper starts from, and the padding below) controls, and that is what
|
|
10889
|
-
* scales.
|
|
10890
|
-
*
|
|
10891
|
-
* The horizontal inset rides along here rather than staying a `px-2` class for
|
|
10892
|
-
* the same reason the vertical padding does: it is derived from `topLen` — the
|
|
10893
|
-
* curve is only knowable once you know how far down the first row starts (see
|
|
10894
|
-
* {@link TRANSCRIPT_INSET_X}) — and splitting a derived pair across a class and
|
|
10895
|
-
* a style object is exactly how the two drift apart.
|
|
10896
|
-
*/
|
|
10897
|
-
function transcriptEdgeFade(topLen) {
|
|
10898
|
-
const at = (fraction) => `calc(${topLen} * ${fraction})`;
|
|
10899
|
-
const gradient = `linear-gradient(to bottom, ${[
|
|
10900
|
-
"transparent 0",
|
|
10901
|
-
`transparent ${at(.5)}`,
|
|
10902
|
-
`rgba(0,0,0,0.25) ${at(.7)}`,
|
|
10903
|
-
`rgba(0,0,0,0.65) ${at(.86)}`,
|
|
10904
|
-
`#000 ${topLen}`,
|
|
10905
|
-
`#000 calc(100% - ${TRANSCRIPT_FADE_BOTTOM_LEN})`,
|
|
10906
|
-
"rgba(0,0,0,0.86) calc(100% - 96px)",
|
|
10907
|
-
"rgba(0,0,0,0.60) calc(100% - 72px)",
|
|
10908
|
-
"rgba(0,0,0,0.32) calc(100% - 48px)",
|
|
10909
|
-
"rgba(0,0,0,0.10) calc(100% - 24px)",
|
|
10910
|
-
"transparent 100%"
|
|
10911
|
-
].join(", ")})`;
|
|
10912
|
-
return {
|
|
10913
|
-
maskImage: gradient,
|
|
10914
|
-
WebkitMaskImage: gradient,
|
|
10915
|
-
paddingTop: topLen,
|
|
10916
|
-
paddingBottom: TRANSCRIPT_FADE_BOTTOM_LEN,
|
|
10917
|
-
paddingInline: TRANSCRIPT_INSET_X
|
|
10918
|
-
};
|
|
10919
|
-
}
|
|
10920
|
-
/** Both variants built once — neither depends on props beyond badge presence. */
|
|
10921
|
-
var TRANSCRIPT_EDGE_FADE = transcriptEdgeFade(TRANSCRIPT_FADE_TOP_LEN);
|
|
10922
|
-
var TRANSCRIPT_EDGE_FADE_WITH_BADGE = transcriptEdgeFade(TRANSCRIPT_FADE_TOP_WITH_BADGE_LEN);
|
|
10923
10966
|
/**
|
|
10924
|
-
*
|
|
10925
|
-
*
|
|
10926
|
-
*
|
|
10927
|
-
* - `'connecting'` → `connecting`
|
|
10928
|
-
* - `'waiting'` (the agent is thinking, between the caller's turn ending and
|
|
10929
|
-
* the reply starting) → `thinking`
|
|
10930
|
-
* - `'live'` + `agentSpeaking` → `speaking`
|
|
10931
|
-
* - `'live'` otherwise → `listening`
|
|
10932
|
-
* - `'idle'` / `'blocked'` → `null`, no pill
|
|
10967
|
+
* Languages written right-to-left. Keyed on the language subtag, so a region
|
|
10968
|
+
* never has to be enumerated.
|
|
10933
10969
|
*
|
|
10934
|
-
*
|
|
10935
|
-
* this
|
|
10936
|
-
*
|
|
10937
|
-
*
|
|
10938
|
-
* given" contract every other optional field on this interface follows.
|
|
10970
|
+
* Beyond Arabic on purpose: Hebrew, Farsi, Urdu and Pashto are the scripts a CX
|
|
10971
|
+
* product in this region acquires next, and getting one wrong is the same silent
|
|
10972
|
+
* failure. Adding a language to the product must not also require remembering
|
|
10973
|
+
* this file.
|
|
10939
10974
|
*/
|
|
10940
|
-
|
|
10941
|
-
|
|
10942
|
-
|
|
10943
|
-
|
|
10944
|
-
|
|
10945
|
-
|
|
10946
|
-
|
|
10947
|
-
|
|
10948
|
-
|
|
10975
|
+
var RTL_LANGUAGES = /* @__PURE__ */ new Set([
|
|
10976
|
+
"ar",
|
|
10977
|
+
"he",
|
|
10978
|
+
"iw",
|
|
10979
|
+
"fa",
|
|
10980
|
+
"ur",
|
|
10981
|
+
"ps",
|
|
10982
|
+
"sd",
|
|
10983
|
+
"ug",
|
|
10984
|
+
"yi",
|
|
10985
|
+
"dv"
|
|
10986
|
+
]);
|
|
10987
|
+
/** Known LTR languages this product targets, so a typo does not silently pass. */
|
|
10988
|
+
var KNOWN_LTR_LANGUAGES = /* @__PURE__ */ new Set([
|
|
10989
|
+
"en",
|
|
10990
|
+
"hi",
|
|
10991
|
+
"es",
|
|
10992
|
+
"fr",
|
|
10993
|
+
"de",
|
|
10994
|
+
"pt",
|
|
10995
|
+
"it",
|
|
10996
|
+
"nl",
|
|
10997
|
+
"id",
|
|
10998
|
+
"ta",
|
|
10999
|
+
"te",
|
|
11000
|
+
"bn",
|
|
11001
|
+
"mr",
|
|
11002
|
+
"gu",
|
|
11003
|
+
"kn",
|
|
11004
|
+
"ml",
|
|
11005
|
+
"pa"
|
|
11006
|
+
]);
|
|
11007
|
+
/** A well-formed BCP-47-ish language subtag: two or three ASCII letters. */
|
|
11008
|
+
var LANGUAGE_SUBTAG = /^[a-z]{2,3}$/;
|
|
10949
11009
|
/**
|
|
10950
|
-
* The
|
|
10951
|
-
*
|
|
10952
|
-
*
|
|
10953
|
-
*
|
|
10954
|
-
*
|
|
11010
|
+
* The base direction for text in `locale`.
|
|
11011
|
+
*
|
|
11012
|
+
* @param locale BCP-47 tag from stored conversation data — untyped by the time
|
|
11013
|
+
* it reaches here, so anything malformed resolves to `auto` rather than to a
|
|
11014
|
+
* guess.
|
|
10955
11015
|
*/
|
|
10956
|
-
function
|
|
10957
|
-
|
|
10958
|
-
|
|
10959
|
-
|
|
10960
|
-
|
|
10961
|
-
|
|
10962
|
-
|
|
11016
|
+
function textDirectionFor$1(locale) {
|
|
11017
|
+
if (locale === void 0 || locale === null || locale === "") return "auto";
|
|
11018
|
+
const language = locale.toLowerCase().split("-")[0] ?? "";
|
|
11019
|
+
if (!LANGUAGE_SUBTAG.test(language)) return "auto";
|
|
11020
|
+
if (RTL_LANGUAGES.has(language)) return "rtl";
|
|
11021
|
+
if (KNOWN_LTR_LANGUAGES.has(language)) return "ltr";
|
|
11022
|
+
return "auto";
|
|
10963
11023
|
}
|
|
11024
|
+
//#endregion
|
|
11025
|
+
//#region src/text-direction.ts
|
|
11026
|
+
var textDirectionFor = textDirectionFor$1;
|
|
11027
|
+
//#endregion
|
|
11028
|
+
//#region src/widget-markdown.tsx
|
|
10964
11029
|
/**
|
|
10965
|
-
*
|
|
10966
|
-
*
|
|
10967
|
-
*
|
|
10968
|
-
* `
|
|
10969
|
-
*
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
|
|
10976
|
-
case "connecting": return "var(--brand-amber)";
|
|
10977
|
-
case "thinking": return "var(--brand-plum)";
|
|
10978
|
-
case "listening":
|
|
10979
|
-
case "speaking": return "var(--brand-rose)";
|
|
10980
|
-
}
|
|
11030
|
+
* Only `http(s)` and `mailto` survive.
|
|
11031
|
+
*
|
|
11032
|
+
* A model can emit `[click here](javascript:…)` as easily as a real URL, and a
|
|
11033
|
+
* bare `href` would execute it on click. Anything else renders as plain text,
|
|
11034
|
+
* so a rejected link still shows its label rather than vanishing.
|
|
11035
|
+
*/
|
|
11036
|
+
function safeHref(raw) {
|
|
11037
|
+
const href = raw.trim();
|
|
11038
|
+
if (/^https?:\/\//i.test(href)) return href;
|
|
11039
|
+
if (/^mailto:[^\s]+@[^\s]+$/i.test(href)) return href;
|
|
11040
|
+
return null;
|
|
10981
11041
|
}
|
|
10982
11042
|
/**
|
|
10983
|
-
* The
|
|
10984
|
-
*
|
|
10985
|
-
*
|
|
11043
|
+
* The bidi embedding and isolate controls (U+202A-U+202E, U+2066-U+2069),
|
|
11044
|
+
* removed from what a bubble shows (SAA-436). A right-to-left override typed
|
|
11045
|
+
* into a message reverses the rest of it on screen ("exe.txt" spoofing); the
|
|
11046
|
+
* bubble's own `dir="auto"` and `unicode-bidi: isolate` already order real
|
|
11047
|
+
* mixed-direction text, so nothing legitimate needs them.
|
|
10986
11048
|
*/
|
|
10987
|
-
|
|
11049
|
+
function stripBidiControls(text) {
|
|
11050
|
+
return text.replace(/[\u202A-\u202E\u2066-\u2069]/g, "");
|
|
11051
|
+
}
|
|
10988
11052
|
/**
|
|
10989
|
-
*
|
|
10990
|
-
*
|
|
11053
|
+
* Inline constructs, innermost-last.
|
|
11054
|
+
*
|
|
11055
|
+
* Code is matched FIRST and never recurses into its own body: `` `**not
|
|
11056
|
+
* bold**` `` is a literal in every Markdown dialect, and parsing emphasis
|
|
11057
|
+
* inside it is the classic way a renderer mangles a code sample.
|
|
10991
11058
|
*/
|
|
10992
|
-
|
|
10993
|
-
|
|
10994
|
-
|
|
10995
|
-
|
|
10996
|
-
|
|
10997
|
-
|
|
10998
|
-
|
|
10999
|
-
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
-
|
|
11003
|
-
|
|
11004
|
-
if (
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
|
|
11059
|
+
function parseInline(src) {
|
|
11060
|
+
const out = [];
|
|
11061
|
+
let rest = src;
|
|
11062
|
+
while (rest.length > 0) {
|
|
11063
|
+
const match = /`([^`]+)`|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|(?<!\*)\*(?!\s)([^*\n]+?)\*(?!\*)|(?<!_)_(?!\s)([^_\n]+?)_(?!_)|\[([^\]]*)\]\(([^)\s]+)\)|(https:\/\/[^\s<>"'`]*[^\s<>"'`.,;:!?)\]])/.exec(rest);
|
|
11064
|
+
if (!match || match.index === void 0) {
|
|
11065
|
+
out.push({
|
|
11066
|
+
kind: "text",
|
|
11067
|
+
text: rest
|
|
11068
|
+
});
|
|
11069
|
+
break;
|
|
11070
|
+
}
|
|
11071
|
+
if (match.index > 0) out.push({
|
|
11072
|
+
kind: "text",
|
|
11073
|
+
text: rest.slice(0, match.index)
|
|
11074
|
+
});
|
|
11075
|
+
const [full, code, boldStar, boldUnd, italStar, italUnd, linkText, linkHref, bare] = match;
|
|
11076
|
+
if (code !== void 0) out.push({
|
|
11077
|
+
kind: "code",
|
|
11078
|
+
text: code
|
|
11079
|
+
});
|
|
11080
|
+
else if (boldStar !== void 0 || boldUnd !== void 0) out.push({
|
|
11081
|
+
kind: "bold",
|
|
11082
|
+
children: parseInline(boldStar ?? boldUnd)
|
|
11083
|
+
});
|
|
11084
|
+
else if (italStar !== void 0 || italUnd !== void 0) out.push({
|
|
11085
|
+
kind: "italic",
|
|
11086
|
+
children: parseInline(italStar ?? italUnd)
|
|
11087
|
+
});
|
|
11088
|
+
else if (linkHref !== void 0) {
|
|
11089
|
+
const href = safeHref(linkHref);
|
|
11090
|
+
const children = parseInline(linkText ?? "").flatMap((n) => n.kind === "link" ? n.children : [n]);
|
|
11091
|
+
out.push(href ? {
|
|
11092
|
+
kind: "link",
|
|
11093
|
+
href,
|
|
11094
|
+
children
|
|
11095
|
+
} : {
|
|
11096
|
+
kind: "text",
|
|
11097
|
+
text: linkText ?? ""
|
|
11098
|
+
});
|
|
11099
|
+
} else if (bare !== void 0) out.push({
|
|
11100
|
+
kind: "link",
|
|
11101
|
+
href: bare,
|
|
11102
|
+
children: [{
|
|
11103
|
+
kind: "text",
|
|
11104
|
+
text: bare
|
|
11105
|
+
}]
|
|
11106
|
+
});
|
|
11107
|
+
rest = rest.slice(match.index + full.length);
|
|
11108
|
+
}
|
|
11109
|
+
return out.filter((n) => !(n.kind === "text" && n.text === ""));
|
|
11110
|
+
}
|
|
11111
|
+
function sameOrigin(href) {
|
|
11112
|
+
try {
|
|
11113
|
+
return new URL(href).origin === window.location.origin;
|
|
11114
|
+
} catch {
|
|
11115
|
+
return false;
|
|
11116
|
+
}
|
|
11117
|
+
}
|
|
11118
|
+
function renderInline(nodes, keyPrefix) {
|
|
11119
|
+
return nodes.map((node, i) => {
|
|
11120
|
+
const key = `${keyPrefix}-${i}`;
|
|
11121
|
+
switch (node.kind) {
|
|
11122
|
+
case "text": return /* @__PURE__ */ jsx(Fragment$1, { children: node.text }, key);
|
|
11123
|
+
case "bold": return /* @__PURE__ */ jsx("strong", { children: renderInline(node.children, key) }, key);
|
|
11124
|
+
case "italic": return /* @__PURE__ */ jsx("em", { children: renderInline(node.children, key) }, key);
|
|
11125
|
+
case "code": return /* @__PURE__ */ jsx("code", {
|
|
11126
|
+
className: "rounded bg-black/10 px-1 py-0.5 font-mono text-[0.85em]",
|
|
11127
|
+
children: node.text
|
|
11128
|
+
}, key);
|
|
11129
|
+
case "link": return /* @__PURE__ */ jsx("a", {
|
|
11130
|
+
href: node.href,
|
|
11131
|
+
...sameOrigin(node.href) ? {} : {
|
|
11132
|
+
target: "_blank",
|
|
11133
|
+
rel: "noopener noreferrer nofollow"
|
|
11134
|
+
},
|
|
11135
|
+
className: "underline underline-offset-2 [overflow-wrap:anywhere]",
|
|
11136
|
+
children: renderInline(node.children, key)
|
|
11137
|
+
}, key);
|
|
11138
|
+
}
|
|
11139
|
+
});
|
|
11140
|
+
}
|
|
11141
|
+
var BULLET = /^\s*[-*+]\s+(.*)$/;
|
|
11142
|
+
var ORDERED = /^\s*\d+[.)]\s+(.*)$/;
|
|
11143
|
+
/**
|
|
11144
|
+
* Group lines into blocks.
|
|
11145
|
+
*
|
|
11146
|
+
* A blank line always closes the current block; a list item closes a paragraph
|
|
11147
|
+
* and vice versa. That last rule is what fixes the reported bug — the model
|
|
11148
|
+
* writes its intro and its bullets with no blank line between them, so
|
|
11149
|
+
* splitting on blank lines alone left `intro - item - item` as one paragraph.
|
|
11150
|
+
*/
|
|
11151
|
+
function parseBlocks(markdown) {
|
|
11152
|
+
const blocks = [];
|
|
11153
|
+
let paragraph = [];
|
|
11154
|
+
let list = null;
|
|
11155
|
+
const flushParagraph = () => {
|
|
11156
|
+
if (paragraph.length > 0) blocks.push({
|
|
11157
|
+
kind: "paragraph",
|
|
11158
|
+
lines: paragraph
|
|
11159
|
+
});
|
|
11160
|
+
paragraph = [];
|
|
11161
|
+
};
|
|
11162
|
+
const flushList = () => {
|
|
11163
|
+
if (list) blocks.push({
|
|
11164
|
+
kind: "list",
|
|
11165
|
+
ordered: list.ordered,
|
|
11166
|
+
items: list.items
|
|
11167
|
+
});
|
|
11168
|
+
list = null;
|
|
11169
|
+
};
|
|
11170
|
+
for (const line of markdown.split("\n")) {
|
|
11171
|
+
if (line.trim() === "") {
|
|
11172
|
+
flushParagraph();
|
|
11173
|
+
flushList();
|
|
11174
|
+
continue;
|
|
11175
|
+
}
|
|
11176
|
+
const bullet = BULLET.exec(line);
|
|
11177
|
+
const ordered = bullet ? null : ORDERED.exec(line);
|
|
11178
|
+
if (bullet ?? ordered) {
|
|
11179
|
+
flushParagraph();
|
|
11180
|
+
const isOrdered = ordered !== null;
|
|
11181
|
+
const text = (bullet?.[1] ?? ordered?.[1] ?? "").trim();
|
|
11182
|
+
if (list && list.ordered !== isOrdered) flushList();
|
|
11183
|
+
list ??= {
|
|
11184
|
+
ordered: isOrdered,
|
|
11185
|
+
items: []
|
|
11186
|
+
};
|
|
11187
|
+
list.items.push(text);
|
|
11188
|
+
continue;
|
|
11189
|
+
}
|
|
11190
|
+
flushList();
|
|
11191
|
+
paragraph.push(line.trim());
|
|
11192
|
+
}
|
|
11193
|
+
flushParagraph();
|
|
11194
|
+
flushList();
|
|
11195
|
+
return blocks;
|
|
11196
|
+
}
|
|
11197
|
+
/**
|
|
11198
|
+
* Renders one turn's text.
|
|
11199
|
+
*
|
|
11200
|
+
* Safe to call on a PARTIAL string: this runs on every streamed delta, so a
|
|
11201
|
+
* half-written `**bold` is common. Unterminated markers simply fail to match
|
|
11202
|
+
* and render as the literal characters they are, which then resolve
|
|
11203
|
+
* themselves on the delta that closes them — no flicker beyond the marker
|
|
11204
|
+
* briefly showing, and never a thrown parse error mid-stream.
|
|
11205
|
+
*/
|
|
11206
|
+
function WidgetMarkdown({ text }) {
|
|
11207
|
+
return parseBlocks(stripBidiControls(text)).map((block, i) => {
|
|
11208
|
+
if (block.kind === "list") return /* @__PURE__ */ jsx(block.ordered ? "ol" : "ul", {
|
|
11209
|
+
className: `my-1 space-y-1 ps-4 ${block.ordered ? "list-decimal" : "list-disc"}`,
|
|
11210
|
+
children: block.items.map((item, j) => /* @__PURE__ */ jsx("li", { children: renderInline(parseInline(item), `b${i}-i${j}`) }, `b${i}-i${j}`))
|
|
11211
|
+
}, `b${i}`);
|
|
11212
|
+
return /* @__PURE__ */ jsx("p", {
|
|
11213
|
+
className: "[&:not(:first-child)]:mt-2",
|
|
11214
|
+
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}`))
|
|
11215
|
+
}, `b${i}`);
|
|
11216
|
+
});
|
|
11217
|
+
}
|
|
11218
|
+
//#endregion
|
|
11219
|
+
//#region src/widget/mic-button.tsx
|
|
11220
|
+
/**
|
|
11221
|
+
* What the microphone control means right now: start, mute or unmute, or,
|
|
11222
|
+
* ahead of all three, the REASON it means nothing (`labels.unavailable`).
|
|
11223
|
+
*
|
|
11224
|
+
* While connecting, dialling or the browser's prompt still open, it is inert
|
|
11225
|
+
* and busy: one impatient press must not become a second call, or a mute of a
|
|
11226
|
+
* call that does not exist yet. It reports no pressed state then, because
|
|
11227
|
+
* there is no call yet to have muted.
|
|
11228
|
+
*/
|
|
11229
|
+
function micControl(voice) {
|
|
11230
|
+
const connecting = voice.phase === "connecting";
|
|
11231
|
+
const inCall = voice.phase !== "idle";
|
|
11232
|
+
const unusable = voice.disabled === true || voice.phase === "blocked";
|
|
11233
|
+
const connectingLabel = voice.labels.connecting ?? defaultWidgetMessages.voice_state_connecting;
|
|
11234
|
+
const muted = inCall && voice.muted === true;
|
|
11235
|
+
return {
|
|
11236
|
+
label: unusable ? voice.labels.unavailable ?? voice.labels.start : connecting ? connectingLabel : inCall ? (muted ? voice.labels.unmute : voice.labels.mute) ?? voice.labels.start : voice.labels.start,
|
|
11237
|
+
onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
|
|
11238
|
+
disabled: unusable || connecting,
|
|
11239
|
+
busy: connecting,
|
|
11240
|
+
pressed: inCall && !connecting ? muted : void 0,
|
|
11241
|
+
live: inCall && !connecting && !muted,
|
|
11242
|
+
muted,
|
|
11243
|
+
connectingLabel
|
|
11244
|
+
};
|
|
11245
|
+
}
|
|
11246
|
+
/** The microphone control, in the composer and in the call view's controls. */
|
|
11247
|
+
function MicButton({ voice, testId, className }) {
|
|
11248
|
+
const mic = micControl(voice);
|
|
11249
|
+
return /* @__PURE__ */ jsx("button", {
|
|
11250
|
+
type: "button",
|
|
11251
|
+
onClick: mic.onClick,
|
|
11252
|
+
disabled: mic.disabled,
|
|
11253
|
+
"data-testid": testId,
|
|
11254
|
+
title: mic.label,
|
|
11255
|
+
"aria-label": mic.label,
|
|
11256
|
+
"aria-busy": mic.busy || void 0,
|
|
11257
|
+
"aria-pressed": mic.pressed,
|
|
11258
|
+
"data-live": mic.live ? "" : void 0,
|
|
11259
|
+
className: cn(className, mic.busy && "cursor-wait"),
|
|
11260
|
+
children: mic.busy ? /* @__PURE__ */ jsx("span", {
|
|
11261
|
+
"aria-hidden": "true",
|
|
11262
|
+
"data-testid": "widget-mic-spinner",
|
|
11263
|
+
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11264
|
+
size: "sm",
|
|
11265
|
+
label: mic.connectingLabel
|
|
11266
|
+
})
|
|
11267
|
+
}) : mic.muted ? /* @__PURE__ */ jsx(MicOff, {}) : /* @__PURE__ */ jsx(Mic, {})
|
|
11268
|
+
});
|
|
11269
|
+
}
|
|
11270
|
+
//#endregion
|
|
11271
|
+
//#region src/widget/use-follow-bottom.ts
|
|
11272
|
+
/**
|
|
11273
|
+
* How far off the bottom still counts as "following the conversation".
|
|
11274
|
+
*
|
|
11275
|
+
* Not zero: fractional scroll metrics on zoomed and hi-dpi displays never
|
|
11276
|
+
* land exactly on the bottom, and a smooth scroll is still in flight when the
|
|
11277
|
+
* next streamed token resizes the content.
|
|
11278
|
+
*/
|
|
11279
|
+
var FOLLOW_TOLERANCE_PX = 24;
|
|
11280
|
+
/** `smooth`, or `auto` where the visitor asked for less motion. */
|
|
11281
|
+
function scrollBehavior() {
|
|
11282
|
+
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
11283
|
+
}
|
|
11284
|
+
/**
|
|
11285
|
+
* Keeps a scrolling log on its newest line while the reader is there: the
|
|
11286
|
+
* panel's transcript and the call view's turns.
|
|
11287
|
+
*
|
|
11288
|
+
* A rise in `rows`, or any change of `nudge`, jumps to the bottom (with
|
|
11289
|
+
* `keepReader`, only while following: a call delivers turns every few seconds,
|
|
11290
|
+
* and a caller re-reading a card must not be pulled down); a fall in
|
|
11291
|
+
* `rows` does not, because a row going away is not a new turn (SAA-484).
|
|
11292
|
+
* Between turns a `ResizeObserver` on `content` and on the viewport follows a
|
|
11293
|
+
* reply as it streams, but only while following. Only a scroll UP stops
|
|
11294
|
+
* following: a smooth scroll fires `scroll` events on its way down, each short
|
|
11295
|
+
* of the bottom. jsdom and older engines ship no `scrollTo` or
|
|
11296
|
+
* `ResizeObserver`; without them this does nothing rather than throw.
|
|
11297
|
+
*/
|
|
11298
|
+
function useFollowBottom(viewport, content, rows, nudge, keepReader = false) {
|
|
11035
11299
|
const following = useRef(true);
|
|
11300
|
+
const lastRows = useRef(rows);
|
|
11036
11301
|
useEffect(() => {
|
|
11037
|
-
const el =
|
|
11302
|
+
const el = viewport.current;
|
|
11303
|
+
const before = lastRows.current;
|
|
11304
|
+
lastRows.current = rows;
|
|
11305
|
+
if (typeof rows === "number" && typeof before === "number" && rows < before) return;
|
|
11038
11306
|
if (typeof el?.scrollTo !== "function") return;
|
|
11307
|
+
if (keepReader && !following.current) return;
|
|
11039
11308
|
following.current = true;
|
|
11040
11309
|
el.scrollTo({
|
|
11041
11310
|
top: el.scrollHeight,
|
|
11042
|
-
behavior:
|
|
11311
|
+
behavior: scrollBehavior()
|
|
11043
11312
|
});
|
|
11044
|
-
}, [
|
|
11045
|
-
|
|
11046
|
-
* Follow the reply as it STREAMS, not just as it starts.
|
|
11047
|
-
*
|
|
11048
|
-
* `scrollKey` is `turns.length` (`voice-widget.tsx`), so the effect above
|
|
11049
|
-
* fires once, when the agent's turn is appended and still empty or one
|
|
11050
|
-
* token long. Everything after that arrives by SSE into the SAME turn: the
|
|
11051
|
-
* bubble grows downward under a scroll position that was correct when it
|
|
11052
|
-
* was pinned and is stale a word later. The visitor watched the TOP of a
|
|
11053
|
-
* long answer and had to scroll for every line of it — the newest text, the
|
|
11054
|
-
* only part they had not read, was the part off-screen.
|
|
11055
|
-
*
|
|
11056
|
-
* A `ResizeObserver` on the content is what closes that gap: it fires on
|
|
11057
|
-
* every layout change the growing text produces, at whatever rate the
|
|
11058
|
-
* tokens land, with no polling and no dependency on how the host chooses to
|
|
11059
|
-
* stream. `scrollKey` still owns the jump to a NEW turn; this owns staying
|
|
11060
|
-
* there while that turn fills in.
|
|
11061
|
-
*
|
|
11062
|
-
* Gated on `following` so it never fights the visitor. Scrolling up to
|
|
11063
|
-
* re-read an earlier answer while the agent is still typing is an ordinary
|
|
11064
|
-
* thing to do, and a transcript that yanks itself back down every 50ms
|
|
11065
|
-
* makes it impossible. `atBottom` uses a tolerance rather than an equality
|
|
11066
|
-
* — fractional scroll metrics on zoomed or hi-dpi displays never land
|
|
11067
|
-
* exactly, and smooth scrolling is still in flight when the next resize
|
|
11068
|
-
* arrives.
|
|
11069
|
-
*
|
|
11070
|
-
* `behavior: 'auto'`, unlike the jump above: a smooth scroll started every
|
|
11071
|
-
* time a token lands never finishes before the next one restarts it, which
|
|
11072
|
-
* reads as the transcript lagging behind its own text.
|
|
11073
|
-
*/
|
|
11313
|
+
}, [rows, nudge]);
|
|
11314
|
+
const watching = useRef({ el: null });
|
|
11074
11315
|
useEffect(() => {
|
|
11075
|
-
const el =
|
|
11076
|
-
if (
|
|
11077
|
-
|
|
11078
|
-
|
|
11316
|
+
const el = viewport.current;
|
|
11317
|
+
if (watching.current.el === el) return;
|
|
11318
|
+
watching.current.stop?.();
|
|
11319
|
+
watching.current = { el };
|
|
11320
|
+
if (!el || typeof el.scrollTo !== "function" || typeof ResizeObserver === "undefined") return;
|
|
11321
|
+
let lastTop = el.scrollTop;
|
|
11079
11322
|
const onScroll = () => {
|
|
11080
|
-
following.current =
|
|
11323
|
+
if (el.scrollHeight - el.scrollTop - el.clientHeight <= FOLLOW_TOLERANCE_PX) following.current = true;
|
|
11324
|
+
else if (el.scrollTop < lastTop) following.current = false;
|
|
11325
|
+
lastTop = el.scrollTop;
|
|
11081
11326
|
};
|
|
11082
11327
|
const observer = new ResizeObserver(() => {
|
|
11083
|
-
if (
|
|
11084
|
-
el.scrollTo({
|
|
11328
|
+
if (following.current) el.scrollTo({
|
|
11085
11329
|
top: el.scrollHeight,
|
|
11086
11330
|
behavior: "auto"
|
|
11087
11331
|
});
|
|
11088
11332
|
});
|
|
11089
|
-
|
|
11090
|
-
|
|
11333
|
+
if (content.current) observer.observe(content.current);
|
|
11334
|
+
observer.observe(el);
|
|
11091
11335
|
el.addEventListener("scroll", onScroll, { passive: true });
|
|
11092
|
-
|
|
11336
|
+
watching.current.stop = () => {
|
|
11093
11337
|
observer.disconnect();
|
|
11094
11338
|
el.removeEventListener("scroll", onScroll);
|
|
11095
11339
|
};
|
|
11096
|
-
}
|
|
11340
|
+
});
|
|
11341
|
+
useEffect(() => () => {
|
|
11342
|
+
watching.current.stop?.();
|
|
11343
|
+
watching.current = { el: null };
|
|
11344
|
+
}, []);
|
|
11345
|
+
}
|
|
11346
|
+
//#endregion
|
|
11347
|
+
//#region src/widget/call-view.tsx
|
|
11348
|
+
/**
|
|
11349
|
+
* The call view's own words. Kept out of `defaultWidgetMessages` so the dock's
|
|
11350
|
+
* `ui.mjs` does not carry them; a host catalogue overrides any of them by key.
|
|
11351
|
+
*/
|
|
11352
|
+
var defaultCallMessages = {
|
|
11353
|
+
call_your_turn: "Your turn",
|
|
11354
|
+
call_muted: "Muted",
|
|
11355
|
+
call_paused: "Paused",
|
|
11356
|
+
call_mic_blocked: "Mic blocked",
|
|
11357
|
+
call_human: "With a teammate",
|
|
11358
|
+
call_offline: "Offline",
|
|
11359
|
+
call_problem: "Call problem",
|
|
11360
|
+
call_ended: "Call ended",
|
|
11361
|
+
call_interrupted: "Interrupted",
|
|
11362
|
+
call_try_saying: "Try saying",
|
|
11363
|
+
call_to_text: "Type instead",
|
|
11364
|
+
call_back_to_call: "Back to call",
|
|
11365
|
+
call_back_to_chat: "Back to chat",
|
|
11366
|
+
call_summary_added: "Added to your basket: {items}",
|
|
11367
|
+
call_summary_checkout: "Your checkout is ready.",
|
|
11368
|
+
call_on_call: "On call"
|
|
11369
|
+
};
|
|
11370
|
+
/** One message, from the host's catalogue when it has the key. */
|
|
11371
|
+
function callText(messages, key) {
|
|
11372
|
+
return messages[key] ?? defaultCallMessages[key] ?? defaultWidgetMessages[key] ?? "";
|
|
11373
|
+
}
|
|
11374
|
+
/**
|
|
11375
|
+
* The header's one word for each of the fourteen states. A `Record` over the
|
|
11376
|
+
* union, so a new state fails to compile until it has a word.
|
|
11377
|
+
*/
|
|
11378
|
+
var CALL_WORDS = {
|
|
11379
|
+
connecting: "voice_state_connecting",
|
|
11380
|
+
listening: "call_your_turn",
|
|
11381
|
+
thinking: "voice_state_thinking",
|
|
11382
|
+
speaking: "voice_state_speaking",
|
|
11383
|
+
muted: "call_muted",
|
|
11384
|
+
ducked: "call_paused",
|
|
11385
|
+
reconnecting: "dock_still_here",
|
|
11386
|
+
mic_blocked: "call_mic_blocked",
|
|
11387
|
+
human: "call_human",
|
|
11388
|
+
offline: "call_offline",
|
|
11389
|
+
error: "call_problem",
|
|
11390
|
+
typing: "call_your_turn",
|
|
11391
|
+
dormant: "call_your_turn",
|
|
11392
|
+
cards: "call_your_turn"
|
|
11393
|
+
};
|
|
11394
|
+
/**
|
|
11395
|
+
* The states whose reason the host's status line spells out under the header.
|
|
11396
|
+
* All but `ducked` are also announced, as in `widget-view.ts`.
|
|
11397
|
+
*/
|
|
11398
|
+
var EXPLAINED = /* @__PURE__ */ new Set([
|
|
11399
|
+
"muted",
|
|
11400
|
+
"ducked",
|
|
11401
|
+
"reconnecting",
|
|
11402
|
+
"mic_blocked",
|
|
11403
|
+
"human",
|
|
11404
|
+
"offline",
|
|
11405
|
+
"error"
|
|
11406
|
+
]);
|
|
11407
|
+
function callStatus(state, { ended, callerSpeaking }) {
|
|
11408
|
+
const explain = EXPLAINED.has(state);
|
|
11409
|
+
return {
|
|
11410
|
+
word: state === "listening" && callerSpeaking ? "voice_state_listening" : ended && !explain ? "call_ended" : CALL_WORDS[state],
|
|
11411
|
+
explain
|
|
11412
|
+
};
|
|
11413
|
+
}
|
|
11414
|
+
/** `mm:ss`, minutes uncapped. */
|
|
11415
|
+
function formatCallTime(ms) {
|
|
11416
|
+
const s = Math.max(0, Math.floor(ms / 1e3));
|
|
11417
|
+
return `${String(Math.floor(s / 60)).padStart(2, "0")}:${String(s % 60).padStart(2, "0")}`;
|
|
11418
|
+
}
|
|
11419
|
+
var IDLE_CALL_RECORD = {
|
|
11420
|
+
id: 0,
|
|
11421
|
+
active: false,
|
|
11422
|
+
startedAt: null,
|
|
11423
|
+
endedAt: null,
|
|
11424
|
+
from: 0,
|
|
11425
|
+
cart: []
|
|
11426
|
+
};
|
|
11427
|
+
function advanceCallRecord(prev, next) {
|
|
11428
|
+
const talking = next.phase === "live" || next.phase === "waiting";
|
|
11429
|
+
if (next.phase === "idle") {
|
|
11430
|
+
if (!prev.active) return prev;
|
|
11431
|
+
return {
|
|
11432
|
+
...prev,
|
|
11433
|
+
active: false,
|
|
11434
|
+
endedAt: prev.startedAt === null ? null : next.now
|
|
11435
|
+
};
|
|
11436
|
+
}
|
|
11437
|
+
if (!prev.active) return {
|
|
11438
|
+
id: prev.id + 1,
|
|
11439
|
+
active: true,
|
|
11440
|
+
startedAt: talking ? next.now : null,
|
|
11441
|
+
endedAt: null,
|
|
11442
|
+
from: next.turns,
|
|
11443
|
+
cart: next.cart,
|
|
11444
|
+
checkoutFrom: next.checkout
|
|
11445
|
+
};
|
|
11446
|
+
const rec = talking && prev.startedAt === null ? {
|
|
11447
|
+
...prev,
|
|
11448
|
+
startedAt: next.now
|
|
11449
|
+
} : prev;
|
|
11450
|
+
return !rec.checkout && next.checkout && next.checkout !== rec.checkoutFrom ? {
|
|
11451
|
+
...rec,
|
|
11452
|
+
checkout: true
|
|
11453
|
+
} : rec;
|
|
11454
|
+
}
|
|
11455
|
+
function useCallRecord(phase, turns, cart, checkout) {
|
|
11456
|
+
const ref = useRef(IDLE_CALL_RECORD);
|
|
11457
|
+
const mounted = useRef(false);
|
|
11458
|
+
useEffect(() => {
|
|
11459
|
+
mounted.current = true;
|
|
11460
|
+
}, []);
|
|
11461
|
+
ref.current = advanceCallRecord(ref.current, {
|
|
11462
|
+
phase,
|
|
11463
|
+
now: performance.now(),
|
|
11464
|
+
turns: mounted.current ? turns.length : turns.findLastIndex((turn) => turn.event === "call_started") + 1,
|
|
11465
|
+
cart: cart ?? [],
|
|
11466
|
+
checkout
|
|
11467
|
+
});
|
|
11468
|
+
return ref.current;
|
|
11469
|
+
}
|
|
11470
|
+
/** The titles whose quantity grew since the call began, in basket order. */
|
|
11471
|
+
function addedDuringCall(before, after) {
|
|
11472
|
+
const had = new Map(before.map((line) => [line.key, line.quantity]));
|
|
11473
|
+
return after.filter((line) => line.quantity > (had.get(line.key) ?? 0)).map((l) => l.title);
|
|
11474
|
+
}
|
|
11475
|
+
/** A call that is live and counting: the timer and the launcher's label tick. */
|
|
11476
|
+
var counting = (record) => record.active && record.startedAt !== null;
|
|
11477
|
+
/** `performance.now()`, re-read once a second while `running`. */
|
|
11478
|
+
function useNow(running) {
|
|
11479
|
+
const [now, setNow] = useState(() => performance.now());
|
|
11480
|
+
useEffect(() => {
|
|
11481
|
+
if (!running) return;
|
|
11482
|
+
setNow(performance.now());
|
|
11483
|
+
const id = window.setInterval(() => setNow(performance.now()), 1e3);
|
|
11484
|
+
return () => window.clearInterval(id);
|
|
11485
|
+
}, [running]);
|
|
11486
|
+
return now;
|
|
11487
|
+
}
|
|
11488
|
+
var NO_TURNS = [];
|
|
11489
|
+
/**
|
|
11490
|
+
* The panel's call lifecycle. A running call takes the panel over unless the
|
|
11491
|
+
* shopper chose "Type instead"; an ended one shows its summary until they
|
|
11492
|
+
* close it. Both choices hold for that call only: the next one shows again.
|
|
11493
|
+
* Absent `call` (the marketing preview), the call view never shows.
|
|
11494
|
+
*/
|
|
11495
|
+
function useCallMode(voice, call) {
|
|
11496
|
+
const record = useCallRecord(voice?.phase ?? "idle", call?.turns ?? NO_TURNS, call?.cart, call?.checkout);
|
|
11497
|
+
const [textCall, setTextCall] = useState(0);
|
|
11498
|
+
const [closedCall, setClosedCall] = useState(0);
|
|
11499
|
+
const now = useNow(counting(record));
|
|
11500
|
+
return {
|
|
11501
|
+
shown: call !== void 0 && voice !== void 0 && textCall !== record.id && (record.active || record.endedAt !== null && closedCall !== record.id),
|
|
11502
|
+
record,
|
|
11503
|
+
launcherLabel: counting(record) ? `${callText(call?.messages ?? defaultWidgetMessages, "call_on_call")} · ${formatCallTime(now - record.startedAt)}` : void 0,
|
|
11504
|
+
toText: () => setTextCall(record.id),
|
|
11505
|
+
backToCall: () => setTextCall(0),
|
|
11506
|
+
closeSummary: () => setClosedCall(record.id)
|
|
11507
|
+
};
|
|
11508
|
+
}
|
|
11509
|
+
function CallTimer({ record }) {
|
|
11510
|
+
const now = useNow(counting(record));
|
|
11511
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
11512
|
+
role: "timer",
|
|
11513
|
+
"data-testid": "widget-call-timer",
|
|
11514
|
+
className: "wgc-tm",
|
|
11515
|
+
children: [counting(record) ? /* @__PURE__ */ jsx("i", {
|
|
11516
|
+
"aria-hidden": true,
|
|
11517
|
+
"data-testid": "widget-call-live"
|
|
11518
|
+
}) : null, record.startedAt === null ? "00:00" : formatCallTime((record.endedAt ?? now) - record.startedAt)]
|
|
11519
|
+
});
|
|
11520
|
+
}
|
|
11521
|
+
/**
|
|
11522
|
+
* The widget generation's call: a header that names the state, the call's
|
|
11523
|
+
* own turns with their cards, the "Try saying" lines and the call controls,
|
|
11524
|
+
* then the summary once it ends. Styled by `styles/call-view.css` (`.wgc`).
|
|
11525
|
+
* See docs/CONCIERGE_GENERATIONS.md "Call mode".
|
|
11526
|
+
*/
|
|
11527
|
+
function CallView({ state, callerSpeaking = false, turns, renderCards, suggestions, onSay, checkout = false, cart, messages, voice, name, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
|
|
11528
|
+
const t = (key) => callText(messages, key);
|
|
11529
|
+
const ended = !record.active;
|
|
11530
|
+
const { word, explain } = callStatus(state, {
|
|
11531
|
+
ended,
|
|
11532
|
+
callerSpeaking
|
|
11533
|
+
});
|
|
11534
|
+
const [said, setSaid] = useState([]);
|
|
11535
|
+
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);
|
|
11536
|
+
const streamRef = useRef(null);
|
|
11537
|
+
const contentRef = useRef(null);
|
|
11538
|
+
const rootRef = useRef(null);
|
|
11539
|
+
useEffect(() => {
|
|
11540
|
+
const root = rootRef.current;
|
|
11541
|
+
const active = (root?.getRootNode())?.activeElement;
|
|
11542
|
+
if (root && (!active || active === document.body)) (root.querySelector("button.wgc-mk,[data-end]") ?? root.querySelector(".wgc-ctl button,.wgc-sum button"))?.focus();
|
|
11543
|
+
}, []);
|
|
11544
|
+
useFollowBottom(streamRef, contentRef, shown.length, void 0, true);
|
|
11545
|
+
const interrupting = voice.agentSpeaking === true && voice.onInterrupt !== void 0;
|
|
11546
|
+
const fixable = voice.phase === "blocked" && voice.onFixPermission !== void 0;
|
|
11547
|
+
const lines = !ended && onSay && (state === "muted" || state === "listening" && !callerSpeaking) ? suggestions.filter((line) => !said.includes(line)) : [];
|
|
11548
|
+
const added = ended ? addedDuringCall(record.cart, cart ?? []) : [];
|
|
11549
|
+
const mark = /* @__PURE__ */ jsx(AvatarFace, {
|
|
11550
|
+
avatar,
|
|
11551
|
+
state: ended ? "idle" : bot,
|
|
11552
|
+
size: "sm",
|
|
11553
|
+
markSize: 44,
|
|
11554
|
+
muted: voice.muted === true && !ended,
|
|
11555
|
+
...name !== void 0 ? { name } : {}
|
|
11556
|
+
});
|
|
11557
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11558
|
+
ref: rootRef,
|
|
11559
|
+
"data-testid": "widget-call-view",
|
|
11560
|
+
"data-call-state": state,
|
|
11561
|
+
className: "wgc",
|
|
11562
|
+
children: [
|
|
11563
|
+
/* @__PURE__ */ jsxs("div", {
|
|
11564
|
+
className: "wgc-hd",
|
|
11565
|
+
children: [
|
|
11566
|
+
interrupting ? /* @__PURE__ */ jsx("button", {
|
|
11567
|
+
type: "button",
|
|
11568
|
+
"data-testid": "widget-interrupt",
|
|
11569
|
+
"aria-label": voice.labels.interrupt ?? defaultWidgetMessages.dock_interrupt,
|
|
11570
|
+
onClick: () => voice.onInterrupt?.("tap"),
|
|
11571
|
+
className: "wgc-mk",
|
|
11572
|
+
children: mark
|
|
11573
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
11574
|
+
className: "wgc-mk",
|
|
11575
|
+
children: mark
|
|
11576
|
+
}),
|
|
11577
|
+
/* @__PURE__ */ jsx("p", {
|
|
11578
|
+
"data-testid": "widget-voice-state",
|
|
11579
|
+
className: "wgc-st",
|
|
11580
|
+
children: t(word)
|
|
11581
|
+
}),
|
|
11582
|
+
/* @__PURE__ */ jsx("span", {
|
|
11583
|
+
role: "status",
|
|
11584
|
+
"data-testid": "widget-call-announce",
|
|
11585
|
+
className: "sr-only",
|
|
11586
|
+
children: (ended || explain && state !== "ducked") && !(explain && hint) ? t(word) : null
|
|
11587
|
+
}),
|
|
11588
|
+
/* @__PURE__ */ jsx(CallTimer, { record }),
|
|
11589
|
+
actions
|
|
11590
|
+
]
|
|
11591
|
+
}),
|
|
11592
|
+
explain && hint || fixable ? /* @__PURE__ */ jsxs("div", {
|
|
11593
|
+
className: "wgc-hint",
|
|
11594
|
+
children: [explain ? hint : null, fixable ? /* @__PURE__ */ jsx("button", {
|
|
11595
|
+
type: "button",
|
|
11596
|
+
"data-testid": "widget-fix-permission",
|
|
11597
|
+
onClick: voice.onFixPermission,
|
|
11598
|
+
className: "wgc-chip",
|
|
11599
|
+
children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
|
|
11600
|
+
}) : null]
|
|
11601
|
+
}) : null,
|
|
11602
|
+
/* @__PURE__ */ jsx("div", {
|
|
11603
|
+
ref: streamRef,
|
|
11604
|
+
role: "log",
|
|
11605
|
+
className: "wgc-log no-scrollbar",
|
|
11606
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
11607
|
+
ref: contentRef,
|
|
11608
|
+
children: shown.map((turn, i) => {
|
|
11609
|
+
const you = turn.speaker === "caller";
|
|
11610
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
11611
|
+
className: "wgc-t",
|
|
11612
|
+
"data-you": you ? "" : void 0,
|
|
11613
|
+
children: [turn.text.trim() !== "" ? /* @__PURE__ */ jsxs("p", {
|
|
11614
|
+
dir: textDirectionFor(turn.locale),
|
|
11615
|
+
lang: turn.locale,
|
|
11616
|
+
"data-testid": you ? "widget-turn-caller" : "widget-turn-agent",
|
|
11617
|
+
"data-cut": turn.cut || turn.filler ? "" : void 0,
|
|
11618
|
+
"data-cur": i === shown.length - 1 && !ended ? "" : void 0,
|
|
11619
|
+
"data-partial": turn.final === false ? "" : void 0,
|
|
11620
|
+
className: "wgc-tx",
|
|
11621
|
+
children: [stripBidiControls(turn.text), turn.cut ? /* @__PURE__ */ jsx("span", {
|
|
11622
|
+
className: "wgc-cut",
|
|
11623
|
+
children: t("call_interrupted")
|
|
11624
|
+
}) : null]
|
|
11625
|
+
}) : null, !you && turn.cards && turn.cards.items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
11626
|
+
className: "wgc-cards",
|
|
11627
|
+
children: renderCards(turn.cards)
|
|
11628
|
+
}) : null]
|
|
11629
|
+
}, i);
|
|
11630
|
+
})
|
|
11631
|
+
})
|
|
11632
|
+
}),
|
|
11633
|
+
lines.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
11634
|
+
className: "wgc-say",
|
|
11635
|
+
children: [/* @__PURE__ */ jsx("p", { children: t("call_try_saying") }), /* @__PURE__ */ jsx("ul", {
|
|
11636
|
+
"data-testid": "widget-suggestions",
|
|
11637
|
+
"aria-label": messages.suggestions_label,
|
|
11638
|
+
children: lines.map((line) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
11639
|
+
type: "button",
|
|
11640
|
+
"data-testid": "widget-suggestion",
|
|
11641
|
+
className: "wgc-chip",
|
|
11642
|
+
onClick: () => {
|
|
11643
|
+
Promise.resolve(onSay?.(line)).then((sent) => {
|
|
11644
|
+
if (sent !== false) setSaid((prev) => [...prev, line]);
|
|
11645
|
+
});
|
|
11646
|
+
},
|
|
11647
|
+
children: line
|
|
11648
|
+
}) }, line))
|
|
11649
|
+
})]
|
|
11650
|
+
}) : null,
|
|
11651
|
+
ended ? /* @__PURE__ */ jsxs("section", {
|
|
11652
|
+
"data-testid": "widget-call-summary",
|
|
11653
|
+
className: "wgc-sum",
|
|
11654
|
+
children: [
|
|
11655
|
+
added.length > 0 ? /* @__PURE__ */ jsx("p", { children: formatMessage(t("call_summary_added"), { items: added.join(", ") }) }) : null,
|
|
11656
|
+
checkout ? /* @__PURE__ */ jsx("p", { children: t("call_summary_checkout") }) : null,
|
|
11657
|
+
/* @__PURE__ */ jsx("button", {
|
|
11658
|
+
type: "button",
|
|
11659
|
+
"data-testid": "widget-call-back-to-chat",
|
|
11660
|
+
onClick: onBackToChat,
|
|
11661
|
+
children: t("call_back_to_chat")
|
|
11662
|
+
})
|
|
11663
|
+
]
|
|
11664
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
11665
|
+
className: "wgc-ctl",
|
|
11666
|
+
children: [
|
|
11667
|
+
/* @__PURE__ */ jsx(MicButton, {
|
|
11668
|
+
voice,
|
|
11669
|
+
testId: testIds?.mic
|
|
11670
|
+
}),
|
|
11671
|
+
voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11672
|
+
type: "button",
|
|
11673
|
+
"data-testid": testIds?.endCall,
|
|
11674
|
+
"data-end": "",
|
|
11675
|
+
onClick: voice.onEnd,
|
|
11676
|
+
"aria-label": voice.labels.end ?? "",
|
|
11677
|
+
children: /* @__PURE__ */ jsx(PhoneOff, {})
|
|
11678
|
+
}) : null,
|
|
11679
|
+
/* @__PURE__ */ jsx("button", {
|
|
11680
|
+
type: "button",
|
|
11681
|
+
"data-testid": "widget-call-to-text",
|
|
11682
|
+
onClick: onText,
|
|
11683
|
+
"aria-label": t("call_to_text"),
|
|
11684
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
11685
|
+
viewBox: "0 0 24 24",
|
|
11686
|
+
width: "20",
|
|
11687
|
+
height: "20",
|
|
11688
|
+
fill: "none",
|
|
11689
|
+
stroke: "currentColor",
|
|
11690
|
+
strokeWidth: "1.75",
|
|
11691
|
+
"aria-hidden": true,
|
|
11692
|
+
children: /* @__PURE__ */ jsx("path", { d: "M4 20l1.3-4A8 8 0 1 1 8 19z" })
|
|
11693
|
+
})
|
|
11694
|
+
})
|
|
11695
|
+
]
|
|
11696
|
+
})
|
|
11697
|
+
]
|
|
11698
|
+
});
|
|
11699
|
+
}
|
|
11700
|
+
//#endregion
|
|
11701
|
+
//#region src/widget/concierge-shell.tsx
|
|
11702
|
+
/**
|
|
11703
|
+
* Maps the call onto the pill it shows, reusing fields `ConciergeShellVoice`
|
|
11704
|
+
* already carries rather than inventing new plumbing:
|
|
11705
|
+
*
|
|
11706
|
+
* - `'connecting'` → `connecting`
|
|
11707
|
+
* - `'waiting'` (the agent is thinking, between the caller's turn ending and
|
|
11708
|
+
* the reply starting) → `thinking`
|
|
11709
|
+
* - `'live'` + `agentSpeaking` → `speaking`
|
|
11710
|
+
* - `'live'` otherwise → `listening`
|
|
11711
|
+
* - `'idle'` / `'blocked'` → `null`, no pill
|
|
11712
|
+
*
|
|
11713
|
+
* `agentSpeaking` is already a real field on {@link ConciergeShellVoice} —
|
|
11714
|
+
* this function only reads it, it does not require every caller to start
|
|
11715
|
+
* setting it; a caller that never populates it simply never reaches
|
|
11716
|
+
* `'speaking'`, which is exactly the same "renders sensibly with what it is
|
|
11717
|
+
* given" contract every other optional field on this interface follows.
|
|
11718
|
+
*/
|
|
11719
|
+
function voiceStatePillState(voice) {
|
|
11720
|
+
const phase = voice?.phase;
|
|
11721
|
+
return phase === "connecting" ? "connecting" : phase === "waiting" ? "thinking" : phase === "live" ? voice?.agentSpeaking ? "speaking" : "listening" : null;
|
|
11722
|
+
}
|
|
11723
|
+
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 }) {
|
|
11724
|
+
const triggerId = `${idPrefix}-trigger`;
|
|
11725
|
+
const inputId = `${idPrefix}-input`;
|
|
11726
|
+
const panelRef = useRef(null);
|
|
11727
|
+
const transcriptRef = useRef(null);
|
|
11728
|
+
/** The transcript's content box — what grows as a reply streams in. */
|
|
11729
|
+
const transcriptContentRef = useRef(null);
|
|
11730
|
+
const callMode = useCallMode(voice, call);
|
|
11731
|
+
const callLabel = callMode.launcherLabel;
|
|
11732
|
+
/** By id within the shell's own root: a shadow root has its own ids, which `document` cannot see. */
|
|
11733
|
+
const byId = (id) => (panelRef.current?.getRootNode())?.getElementById(id);
|
|
11734
|
+
const focusInput = () => window.setTimeout(() => byId(inputId)?.focus(), 0);
|
|
11735
|
+
/**
|
|
11736
|
+
* The knot's tighten flourish is EDGE-triggered (one play per bump of
|
|
11737
|
+
* `tightenKey`), so it is bumped only on the rising edge of
|
|
11738
|
+
* `messageArrived`, not on every render where it stays `true`.
|
|
11739
|
+
*/
|
|
11740
|
+
const wasMessageArrived = useRef(false);
|
|
11741
|
+
const [knotTightenKey, setKnotTightenKey] = useState(0);
|
|
11742
|
+
useEffect(() => {
|
|
11743
|
+
if (messageArrived && !wasMessageArrived.current) setKnotTightenKey((k) => k + 1);
|
|
11744
|
+
wasMessageArrived.current = messageArrived;
|
|
11745
|
+
}, [messageArrived]);
|
|
11746
|
+
/**
|
|
11747
|
+
* Follow the reply as it STREAMS, not just as it starts: `scrollKey` fires
|
|
11748
|
+
* once per turn, and the tokens after that grow the content box. The
|
|
11749
|
+
* viewport is watched too: the status line and the call row change its
|
|
11750
|
+
* height.
|
|
11751
|
+
*/
|
|
11752
|
+
useFollowBottom(transcriptRef, transcriptContentRef, scrollKey, state);
|
|
11097
11753
|
const skipFocus = useRef(!focusOnOpen);
|
|
11098
11754
|
const handleClose = useCallback(() => {
|
|
11099
11755
|
onOpenChange(false);
|
|
11100
11756
|
window.setTimeout(() => {
|
|
11101
|
-
|
|
11757
|
+
byId(triggerId)?.focus({ preventScroll: true });
|
|
11102
11758
|
}, 400);
|
|
11103
11759
|
}, [onOpenChange, triggerId]);
|
|
11104
11760
|
useEffect(() => {
|
|
@@ -11116,15 +11772,16 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11116
11772
|
if (focusable.length === 0) return;
|
|
11117
11773
|
const first = focusable[0];
|
|
11118
11774
|
const last = focusable[focusable.length - 1];
|
|
11119
|
-
|
|
11775
|
+
const active = panel.getRootNode().activeElement;
|
|
11776
|
+
if (e.shiftKey && active === first) {
|
|
11120
11777
|
e.preventDefault();
|
|
11121
11778
|
last.focus();
|
|
11122
|
-
} else if (!e.shiftKey &&
|
|
11779
|
+
} else if (!e.shiftKey && active === last) {
|
|
11123
11780
|
e.preventDefault();
|
|
11124
11781
|
first.focus();
|
|
11125
11782
|
}
|
|
11126
11783
|
};
|
|
11127
|
-
const focusTimer = skipFocus.current ? void 0 : window.setTimeout(() =>
|
|
11784
|
+
const focusTimer = skipFocus.current ? void 0 : window.setTimeout(() => byId(inputId)?.focus(), 120);
|
|
11128
11785
|
skipFocus.current = false;
|
|
11129
11786
|
window.addEventListener("keydown", onKeyDown);
|
|
11130
11787
|
return () => {
|
|
@@ -11136,52 +11793,23 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11136
11793
|
handleClose,
|
|
11137
11794
|
inputId
|
|
11138
11795
|
]);
|
|
11139
|
-
/**
|
|
11140
|
-
* A call is running — anything but `idle`, including the phases that are not
|
|
11141
|
-
* speakable yet. The composer dims from the moment the caller commits to
|
|
11142
|
-
* voice, not only once the transport catches up.
|
|
11143
|
-
*/
|
|
11796
|
+
/** A call is running — anything but `idle`, including the phases not speakable yet. */
|
|
11144
11797
|
const inCall = voice !== void 0 && voice.phase !== "idle";
|
|
11145
|
-
/**
|
|
11146
|
-
* The voice-state pill's own state — `null` for `'idle'` (covered by
|
|
11147
|
-
* `inCall` too) AND `'blocked'` (NOT covered by `inCall`, which is why this
|
|
11148
|
-
* is its own value rather than reusing that boolean: a refused microphone
|
|
11149
|
-
* is still "a call", but it is not one of the four states the pill knows
|
|
11150
|
-
* how to draw — see `voiceStatePillState`'s own doc comment).
|
|
11151
|
-
*/
|
|
11798
|
+
/** `null` for `idle` and `blocked` — see `voiceStatePillState`. */
|
|
11152
11799
|
const voicePillState = voiceStatePillState(voice);
|
|
11153
|
-
/**
|
|
11154
|
-
* The call has been asked for and has not answered yet — the transport
|
|
11155
|
-
* dialing, or the browser's own microphone prompt still open in front of
|
|
11156
|
-
* the caller (the host folds both into this one phase; see
|
|
11157
|
-
* `useVoiceSession`'s `micPending` and `host-widget.tsx`'s `callPhase`).
|
|
11158
|
-
*
|
|
11159
|
-
* For as long as it lasts, the round control is a SPINNER and is inert. A
|
|
11160
|
-
* microphone glyph here says "talk now" during the one stretch where
|
|
11161
|
-
* talking provably does nothing, and a pressable one turns a single
|
|
11162
|
-
* impatient gesture into either a second call or a mute of a call that does
|
|
11163
|
-
* not exist yet. The wait ends by itself, in one of two directions: `live`
|
|
11164
|
-
* (the microphone comes back) or `blocked` (the existing refused
|
|
11165
|
-
* presentation) — never in a spinner nobody can clear.
|
|
11166
|
-
*/
|
|
11167
|
-
const connecting = voice?.phase === "connecting";
|
|
11168
11800
|
/** No voice leg to press at all, or a microphone the browser refused. */
|
|
11169
11801
|
const micUnusable = voice !== void 0 && (voice.disabled === true || voice.phase === "blocked");
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
|
|
11175
|
-
|
|
11176
|
-
|
|
11177
|
-
|
|
11178
|
-
|
|
11179
|
-
|
|
11180
|
-
|
|
11181
|
-
* "Connecting" as the name of a button that will now never connect. See
|
|
11182
|
-
* `ConciergeShellVoice.labels.unavailable`.
|
|
11183
|
-
*/
|
|
11184
|
-
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 ?? "";
|
|
11802
|
+
const showEnd = inCall && voice.onEnd !== void 0;
|
|
11803
|
+
/** The call view's own controls, kept in reach while it is not shown. */
|
|
11804
|
+
const interrupting = inCall && voice.agentSpeaking === true && voice.onInterrupt !== void 0;
|
|
11805
|
+
const fixable = voice?.phase === "blocked" && voice.onFixPermission !== void 0;
|
|
11806
|
+
const closeButton = /* @__PURE__ */ jsx("button", {
|
|
11807
|
+
type: "button",
|
|
11808
|
+
className: "wgp-ib",
|
|
11809
|
+
"aria-label": labels.close,
|
|
11810
|
+
onClick: handleClose,
|
|
11811
|
+
children: /* @__PURE__ */ jsx(X, {})
|
|
11812
|
+
});
|
|
11185
11813
|
const counting = draft.length >= WIDGET_MESSAGE_COUNT_FROM;
|
|
11186
11814
|
const submit = (e) => {
|
|
11187
11815
|
e.preventDefault();
|
|
@@ -11205,268 +11833,257 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11205
11833
|
hidden: open,
|
|
11206
11834
|
avatar,
|
|
11207
11835
|
...launcher !== void 0 ? { spec: launcher } : {},
|
|
11208
|
-
...launcherInitials !== void 0 ? { initials: launcherInitials } : {}
|
|
11836
|
+
...launcherInitials !== void 0 ? { initials: launcherInitials } : {},
|
|
11837
|
+
...launcherVariant !== void 0 ? { launcher: launcherVariant } : {},
|
|
11838
|
+
...agentName !== void 0 ? { agentName } : {},
|
|
11839
|
+
...callLabel !== void 0 ? { callLabel } : {}
|
|
11209
11840
|
}),
|
|
11210
11841
|
/* @__PURE__ */ jsx("div", {
|
|
11211
11842
|
"aria-hidden": true,
|
|
11212
|
-
className: cn("
|
|
11843
|
+
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")
|
|
11213
11844
|
}),
|
|
11214
11845
|
/* @__PURE__ */ jsx("div", {
|
|
11215
11846
|
"aria-hidden": !open,
|
|
11216
|
-
className: cn("pointer-events-none fixed inset-x-0 z-50 flex", panelClasses(position)),
|
|
11217
|
-
children: /* @__PURE__ */
|
|
11218
|
-
|
|
11219
|
-
|
|
11847
|
+
className: cn("wgp-row pointer-events-none fixed inset-x-0 z-50 flex", panelClasses(position)),
|
|
11848
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
11849
|
+
ref: panelRef,
|
|
11850
|
+
role: "dialog",
|
|
11851
|
+
"aria-modal": "true",
|
|
11852
|
+
"aria-label": labels.dialog,
|
|
11853
|
+
"data-testid": testIds?.panel,
|
|
11854
|
+
"data-open": open ? "" : void 0,
|
|
11855
|
+
className: cn("wgp origin-bottom", open ? "pointer-events-auto" : "pointer-events-none"),
|
|
11856
|
+
children: callMode.shown && call && voice ? /* @__PURE__ */ jsx(CallView, {
|
|
11857
|
+
...call,
|
|
11858
|
+
voice,
|
|
11859
|
+
...agentName !== void 0 ? { name: agentName } : {},
|
|
11860
|
+
checkout: callMode.record.checkout,
|
|
11861
|
+
actions: closeButton,
|
|
11862
|
+
record: callMode.record,
|
|
11863
|
+
bot: state,
|
|
11864
|
+
avatar,
|
|
11865
|
+
hint: badge,
|
|
11866
|
+
onText: () => {
|
|
11867
|
+
callMode.toText();
|
|
11868
|
+
focusInput();
|
|
11869
|
+
},
|
|
11870
|
+
onBackToChat: () => {
|
|
11871
|
+
callMode.closeSummary();
|
|
11872
|
+
focusInput();
|
|
11873
|
+
},
|
|
11874
|
+
testIds: {
|
|
11875
|
+
...testIds?.mic !== void 0 ? { mic: testIds.mic } : {},
|
|
11876
|
+
...testIds?.endCall !== void 0 ? { endCall: testIds.endCall } : {}
|
|
11877
|
+
}
|
|
11878
|
+
}) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11220
11879
|
/* @__PURE__ */ jsxs("div", {
|
|
11221
|
-
|
|
11222
|
-
role: "dialog",
|
|
11223
|
-
"aria-modal": "true",
|
|
11224
|
-
"aria-label": labels.dialog,
|
|
11225
|
-
"data-testid": testIds?.panel,
|
|
11226
|
-
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"),
|
|
11227
|
-
style: { transitionTimingFunction: "cubic-bezier(0.16, 1, 0.3, 1)" },
|
|
11880
|
+
className: "wgp-hd",
|
|
11228
11881
|
children: [
|
|
11229
|
-
/* @__PURE__ */ jsx("
|
|
11230
|
-
"
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
11240
|
-
WebkitMaskComposite: "xor",
|
|
11241
|
-
maskComposite: "exclude"
|
|
11242
|
-
}
|
|
11882
|
+
/* @__PURE__ */ jsx("span", {
|
|
11883
|
+
className: "wgp-mk",
|
|
11884
|
+
children: /* @__PURE__ */ jsx(AvatarFace, {
|
|
11885
|
+
avatar,
|
|
11886
|
+
state,
|
|
11887
|
+
size: "sm",
|
|
11888
|
+
markSize: 34,
|
|
11889
|
+
messageArrived,
|
|
11890
|
+
tightenKey: knotTightenKey,
|
|
11891
|
+
...agentName !== void 0 ? { name: agentName } : {}
|
|
11892
|
+
})
|
|
11243
11893
|
}),
|
|
11244
|
-
/* @__PURE__ */
|
|
11245
|
-
|
|
11246
|
-
"
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11894
|
+
/* @__PURE__ */ jsxs("div", {
|
|
11895
|
+
className: "wgp-hd-t",
|
|
11896
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
11897
|
+
className: "wgp-name",
|
|
11898
|
+
dir: "auto",
|
|
11899
|
+
children: labels.title ?? labels.dialog
|
|
11900
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
11901
|
+
className: "wgp-sub",
|
|
11902
|
+
children: [
|
|
11903
|
+
/* @__PURE__ */ jsx("span", {
|
|
11904
|
+
"data-testid": "widget-voice-state",
|
|
11905
|
+
className: cn("wgp-pill", voicePillState ? "opacity-100" : "opacity-0"),
|
|
11906
|
+
children: voicePillState ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
11907
|
+
"aria-hidden": true,
|
|
11908
|
+
"data-live": voicePillState === "speaking" || voicePillState === "listening" ? "" : void 0,
|
|
11909
|
+
className: cn(voicePillState !== "listening" && "animate-pulse motion-reduce:animate-none")
|
|
11910
|
+
}), /* @__PURE__ */ jsx("span", { children: voice?.labels[voicePillState] ?? defaultWidgetMessages[`voice_state_${voicePillState}`] })] }) : null
|
|
11911
|
+
}),
|
|
11912
|
+
operatorName === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
11913
|
+
"data-testid": "widget-operator-name",
|
|
11914
|
+
dir: "auto",
|
|
11915
|
+
children: operatorName
|
|
11916
|
+
}),
|
|
11917
|
+
badge
|
|
11918
|
+
]
|
|
11919
|
+
})]
|
|
11250
11920
|
}),
|
|
11251
11921
|
/* @__PURE__ */ jsxs("div", {
|
|
11252
|
-
className:
|
|
11922
|
+
className: "wgp-act",
|
|
11923
|
+
children: [voice && !inCall && !micUnusable ? /* @__PURE__ */ jsx("button", {
|
|
11924
|
+
type: "button",
|
|
11925
|
+
className: "wgp-ib",
|
|
11926
|
+
"data-testid": "widget-voice-cta",
|
|
11927
|
+
"aria-label": voice.labels.start,
|
|
11928
|
+
title: voice.labels.start,
|
|
11929
|
+
onClick: voice.onStart,
|
|
11930
|
+
children: /* @__PURE__ */ jsx(Mic, {})
|
|
11931
|
+
}) : null, closeButton]
|
|
11932
|
+
})
|
|
11933
|
+
]
|
|
11934
|
+
}),
|
|
11935
|
+
/* @__PURE__ */ jsx("div", {
|
|
11936
|
+
ref: transcriptRef,
|
|
11937
|
+
className: "wgp-msgs no-scrollbar",
|
|
11938
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
11939
|
+
ref: transcriptContentRef,
|
|
11940
|
+
children: [
|
|
11941
|
+
children,
|
|
11942
|
+
privacyChoices?.slot ? /* @__PURE__ */ jsx("div", {
|
|
11943
|
+
ref: privacyChoices.slot,
|
|
11944
|
+
className: "wgp-consent"
|
|
11945
|
+
}) : null,
|
|
11946
|
+
typing ? /* @__PURE__ */ jsxs("p", {
|
|
11947
|
+
"data-testid": "widget-typing-indicator",
|
|
11948
|
+
className: "wgp-typing",
|
|
11949
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
11950
|
+
className: "sr-only",
|
|
11951
|
+
children: defaultWidgetMessages.typing
|
|
11952
|
+
}), [
|
|
11953
|
+
0,
|
|
11954
|
+
1,
|
|
11955
|
+
2
|
|
11956
|
+
].map((i) => /* @__PURE__ */ jsx("span", {
|
|
11957
|
+
"aria-hidden": "true",
|
|
11958
|
+
style: {
|
|
11959
|
+
animationDelay: `${i * 150}ms`,
|
|
11960
|
+
animationDuration: "1.2s"
|
|
11961
|
+
}
|
|
11962
|
+
}, i))]
|
|
11963
|
+
}) : null
|
|
11964
|
+
]
|
|
11965
|
+
})
|
|
11966
|
+
}),
|
|
11967
|
+
/* @__PURE__ */ jsxs("form", {
|
|
11968
|
+
className: "wgp-cz",
|
|
11969
|
+
onSubmit: submit,
|
|
11970
|
+
children: [
|
|
11971
|
+
showEnd || interrupting || fixable || call !== void 0 && inCall ? /* @__PURE__ */ jsxs("div", {
|
|
11972
|
+
className: "wgp-call",
|
|
11973
|
+
children: [
|
|
11974
|
+
fixable ? /* @__PURE__ */ jsx("button", {
|
|
11975
|
+
type: "button",
|
|
11976
|
+
onClick: voice.onFixPermission,
|
|
11977
|
+
"data-testid": "widget-fix-permission",
|
|
11978
|
+
className: "wgp-fix",
|
|
11979
|
+
children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
|
|
11980
|
+
}) : null,
|
|
11981
|
+
interrupting ? /* @__PURE__ */ jsx("button", {
|
|
11982
|
+
type: "button",
|
|
11983
|
+
onClick: () => voice.onInterrupt?.("tap"),
|
|
11984
|
+
"data-testid": "widget-interrupt",
|
|
11985
|
+
"aria-label": voice.labels.interrupt ?? defaultWidgetMessages.dock_interrupt,
|
|
11986
|
+
className: "wgp-ib",
|
|
11987
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
11988
|
+
viewBox: "0 0 24 24",
|
|
11989
|
+
width: "20",
|
|
11990
|
+
height: "20",
|
|
11991
|
+
"aria-hidden": true,
|
|
11992
|
+
children: /* @__PURE__ */ jsx("rect", {
|
|
11993
|
+
x: "7",
|
|
11994
|
+
y: "7",
|
|
11995
|
+
width: "10",
|
|
11996
|
+
height: "10",
|
|
11997
|
+
rx: "2",
|
|
11998
|
+
fill: "currentColor"
|
|
11999
|
+
})
|
|
12000
|
+
})
|
|
12001
|
+
}) : null,
|
|
12002
|
+
call !== void 0 && inCall ? /* @__PURE__ */ jsx("button", {
|
|
12003
|
+
type: "button",
|
|
12004
|
+
onClick: callMode.backToCall,
|
|
12005
|
+
"data-testid": "widget-back-to-call",
|
|
12006
|
+
className: "wgp-fix",
|
|
12007
|
+
children: callText(call.messages, "call_back_to_call")
|
|
12008
|
+
}) : null,
|
|
12009
|
+
showEnd ? /* @__PURE__ */ jsx("button", {
|
|
12010
|
+
type: "button",
|
|
12011
|
+
onClick: voice.onEnd,
|
|
12012
|
+
"data-testid": testIds?.endCall,
|
|
12013
|
+
title: voice.labels.end ?? "",
|
|
12014
|
+
"aria-label": voice.labels.end ?? "",
|
|
12015
|
+
"data-end": "",
|
|
12016
|
+
className: "wgp-ib",
|
|
12017
|
+
children: /* @__PURE__ */ jsx(PhoneOff, {})
|
|
12018
|
+
}) : null
|
|
12019
|
+
]
|
|
12020
|
+
}) : null,
|
|
12021
|
+
counting ? /* @__PURE__ */ jsxs("span", {
|
|
12022
|
+
id: `${inputId}-count`,
|
|
12023
|
+
"data-testid": "widget-composer-count",
|
|
12024
|
+
className: "wgp-count",
|
|
12025
|
+
children: [
|
|
12026
|
+
draft.length,
|
|
12027
|
+
"/",
|
|
12028
|
+
WIDGET_MESSAGE_MAX_LENGTH
|
|
12029
|
+
]
|
|
12030
|
+
}) : null,
|
|
12031
|
+
/* @__PURE__ */ jsxs("div", {
|
|
12032
|
+
className: "wgp-field",
|
|
11253
12033
|
children: [
|
|
11254
|
-
|
|
11255
|
-
|
|
11256
|
-
|
|
12034
|
+
composerLeading,
|
|
12035
|
+
/* @__PURE__ */ jsx("label", {
|
|
12036
|
+
htmlFor: inputId,
|
|
12037
|
+
className: "sr-only",
|
|
12038
|
+
children: labels.composerPlaceholder
|
|
11257
12039
|
}),
|
|
11258
|
-
/* @__PURE__ */ jsx("
|
|
11259
|
-
|
|
11260
|
-
|
|
12040
|
+
/* @__PURE__ */ jsx("input", {
|
|
12041
|
+
id: inputId,
|
|
12042
|
+
"data-testid": testIds?.input,
|
|
12043
|
+
value: draft,
|
|
12044
|
+
onChange: (e) => onDraftChange(e.target.value),
|
|
12045
|
+
placeholder: labels.composerPlaceholder,
|
|
12046
|
+
dir: "auto",
|
|
12047
|
+
maxLength: WIDGET_MESSAGE_MAX_LENGTH,
|
|
12048
|
+
...counting ? { "aria-describedby": `${inputId}-count` } : {},
|
|
12049
|
+
disabled: composerDisabled,
|
|
12050
|
+
autoComplete: "off",
|
|
12051
|
+
className: cn("wgp-in", inCall && draft === "" && "opacity-60 focus:opacity-100")
|
|
11261
12052
|
}),
|
|
11262
|
-
/* @__PURE__ */
|
|
11263
|
-
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
|
|
11268
|
-
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
11272
|
-
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
size: "lg",
|
|
11276
|
-
messageArrived,
|
|
11277
|
-
tightenKey: knotTightenKey
|
|
11278
|
-
})]
|
|
11279
|
-
}), /* @__PURE__ */ jsx("div", {
|
|
11280
|
-
"data-testid": "widget-voice-state",
|
|
11281
|
-
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"),
|
|
11282
|
-
children: voicePillState ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
11283
|
-
"aria-hidden": true,
|
|
11284
|
-
className: cn("size-1.5 shrink-0 rounded-full", voicePillState !== "listening" && "animate-pulse motion-reduce:animate-none"),
|
|
11285
|
-
style: { backgroundColor: voiceStatePillDotColor(voicePillState) }
|
|
11286
|
-
}), /* @__PURE__ */ jsx("span", { children: voiceStatePillLabel(voicePillState, voice?.labels) })] }) : null
|
|
11287
|
-
})]
|
|
11288
|
-
}),
|
|
11289
|
-
badge == null && operatorName === void 0 ? null : /* @__PURE__ */ jsxs("div", {
|
|
11290
|
-
className: "z-10 mt-[104px] w-[68%] shrink-0 text-center",
|
|
11291
|
-
children: [operatorName === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
11292
|
-
"data-testid": "widget-operator-name",
|
|
11293
|
-
dir: "auto",
|
|
11294
|
-
className: "text-[11px] font-medium text-[var(--widget-foreground-muted)]",
|
|
11295
|
-
children: operatorName
|
|
11296
|
-
}), badge]
|
|
11297
|
-
}),
|
|
11298
|
-
/* @__PURE__ */ jsx("div", {
|
|
11299
|
-
ref: transcriptRef,
|
|
11300
|
-
className: "no-scrollbar w-full min-h-0 flex-1 overflow-y-auto",
|
|
11301
|
-
style: badge == null ? TRANSCRIPT_EDGE_FADE : TRANSCRIPT_EDGE_FADE_WITH_BADGE,
|
|
11302
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
11303
|
-
ref: transcriptContentRef,
|
|
11304
|
-
children: [
|
|
11305
|
-
children,
|
|
11306
|
-
privacyChoices?.slot ? /* @__PURE__ */ jsx("div", { ref: privacyChoices.slot }) : null,
|
|
11307
|
-
typing ? /* @__PURE__ */ jsxs("p", {
|
|
11308
|
-
"data-testid": "widget-typing-indicator",
|
|
11309
|
-
className: "flex items-center gap-1 px-1 py-1 text-[var(--widget-foreground-muted)]",
|
|
11310
|
-
children: [/* @__PURE__ */ jsx("span", {
|
|
11311
|
-
className: "sr-only",
|
|
11312
|
-
children: defaultWidgetMessages.typing
|
|
11313
|
-
}), [
|
|
11314
|
-
0,
|
|
11315
|
-
1,
|
|
11316
|
-
2
|
|
11317
|
-
].map((i) => /* @__PURE__ */ jsx("span", {
|
|
11318
|
-
"aria-hidden": "true",
|
|
11319
|
-
className: "h-1.5 w-1.5 animate-bounce rounded-full bg-current motion-reduce:animate-none",
|
|
11320
|
-
style: {
|
|
11321
|
-
animationDelay: `${i * 140}ms`,
|
|
11322
|
-
animationDuration: "1s"
|
|
11323
|
-
}
|
|
11324
|
-
}, i))]
|
|
11325
|
-
}) : null
|
|
11326
|
-
]
|
|
11327
|
-
})
|
|
11328
|
-
}),
|
|
11329
|
-
/* @__PURE__ */ jsx("div", {
|
|
11330
|
-
"aria-hidden": true,
|
|
11331
|
-
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))]",
|
|
11332
|
-
style: { height: COMPOSER_GROUND_LEN }
|
|
11333
|
-
}),
|
|
11334
|
-
/* @__PURE__ */ jsx("div", {
|
|
11335
|
-
className: "pointer-events-none absolute inset-x-0 z-20 flex justify-center",
|
|
11336
|
-
style: { bottom: voice ? COMPOSER_BOTTOM_LEN : COMPOSER_BOTTOM_NO_VOICE_LEN },
|
|
11337
|
-
children: /* @__PURE__ */ jsxs("div", {
|
|
11338
|
-
className: cn("flex w-[71%] flex-col items-center gap-2.5", open ? "pointer-events-auto" : "pointer-events-none"),
|
|
11339
|
-
style: { maxWidth: COMPOSER_MAX_WIDTH_LEN },
|
|
11340
|
-
children: [/* @__PURE__ */ jsxs("form", {
|
|
11341
|
-
className: "flex w-full items-center gap-2",
|
|
11342
|
-
onSubmit: submit,
|
|
11343
|
-
children: [composerLeading, /* @__PURE__ */ jsxs("div", {
|
|
11344
|
-
className: "relative flex-1",
|
|
11345
|
-
children: [
|
|
11346
|
-
/* @__PURE__ */ jsx("label", {
|
|
11347
|
-
htmlFor: inputId,
|
|
11348
|
-
className: "sr-only",
|
|
11349
|
-
children: labels.composerPlaceholder
|
|
11350
|
-
}),
|
|
11351
|
-
/* @__PURE__ */ jsx("input", {
|
|
11352
|
-
id: inputId,
|
|
11353
|
-
"data-testid": testIds?.input,
|
|
11354
|
-
value: draft,
|
|
11355
|
-
onChange: (e) => onDraftChange(e.target.value),
|
|
11356
|
-
placeholder: labels.composerPlaceholder,
|
|
11357
|
-
dir: "auto",
|
|
11358
|
-
maxLength: WIDGET_MESSAGE_MAX_LENGTH,
|
|
11359
|
-
...counting ? { "aria-describedby": `${inputId}-count` } : {},
|
|
11360
|
-
disabled: composerDisabled,
|
|
11361
|
-
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")
|
|
11362
|
-
}),
|
|
11363
|
-
counting ? /* @__PURE__ */ jsxs("span", {
|
|
11364
|
-
id: `${inputId}-count`,
|
|
11365
|
-
"data-testid": "widget-composer-count",
|
|
11366
|
-
className: "absolute end-4 -top-5 text-[11px] text-[var(--widget-foreground-muted)] tabular-nums",
|
|
11367
|
-
children: [
|
|
11368
|
-
draft.length,
|
|
11369
|
-
"/",
|
|
11370
|
-
WIDGET_MESSAGE_MAX_LENGTH
|
|
11371
|
-
]
|
|
11372
|
-
}) : null,
|
|
11373
|
-
draft.trim() && /* @__PURE__ */ jsx("button", {
|
|
11374
|
-
type: "submit",
|
|
11375
|
-
"aria-label": labels.send,
|
|
11376
|
-
"data-testid": testIds?.send,
|
|
11377
|
-
disabled: composerDisabled,
|
|
11378
|
-
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",
|
|
11379
|
-
children: /* @__PURE__ */ jsx(Send, { className: "size-4 rtl:-scale-x-100" })
|
|
11380
|
-
})
|
|
11381
|
-
]
|
|
11382
|
-
})]
|
|
11383
|
-
}), voice ? /* @__PURE__ */ jsxs("div", {
|
|
11384
|
-
className: "mt-1 flex items-center gap-3",
|
|
11385
|
-
children: [
|
|
11386
|
-
/* @__PURE__ */ jsx("button", {
|
|
11387
|
-
type: "button",
|
|
11388
|
-
onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
|
|
11389
|
-
disabled: micUnusable || connecting,
|
|
11390
|
-
"data-testid": testIds?.mic,
|
|
11391
|
-
title: micLabel,
|
|
11392
|
-
"aria-label": micLabel,
|
|
11393
|
-
...connecting ? { "aria-busy": true } : {},
|
|
11394
|
-
...inCall && !connecting ? { "aria-pressed": voice.muted ?? false } : {},
|
|
11395
|
-
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"),
|
|
11396
|
-
children: connecting ? /* @__PURE__ */ jsx("span", {
|
|
11397
|
-
"aria-hidden": "true",
|
|
11398
|
-
"data-testid": "widget-mic-spinner",
|
|
11399
|
-
className: "flex items-center justify-center",
|
|
11400
|
-
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11401
|
-
size: "md",
|
|
11402
|
-
variant: "light",
|
|
11403
|
-
label: connectingLabel
|
|
11404
|
-
})
|
|
11405
|
-
}) : inCall && voice.muted === true ? /* @__PURE__ */ jsx(MicOff, { className: "size-5" }) : /* @__PURE__ */ jsx(Mic, { className: "size-5" })
|
|
11406
|
-
}),
|
|
11407
|
-
inCall && voice.agentSpeaking === true && voice.onInterrupt !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11408
|
-
type: "button",
|
|
11409
|
-
onClick: () => voice.onInterrupt?.("tap"),
|
|
11410
|
-
"data-testid": "widget-interrupt",
|
|
11411
|
-
title: voice.labels.interrupt ?? "",
|
|
11412
|
-
"aria-label": voice.labels.interrupt ?? "",
|
|
11413
|
-
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"),
|
|
11414
|
-
children: /* @__PURE__ */ jsx(Square, { className: "size-4" })
|
|
11415
|
-
}) : null,
|
|
11416
|
-
voice.phase === "blocked" && voice.onFixPermission !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11417
|
-
type: "button",
|
|
11418
|
-
onClick: voice.onFixPermission,
|
|
11419
|
-
"data-testid": "widget-fix-permission",
|
|
11420
|
-
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"),
|
|
11421
|
-
children: voice.labels.fixBrowser ?? defaultWidgetMessages.dock_fix_browser
|
|
11422
|
-
}) : null,
|
|
11423
|
-
inCall && voice.onEnd !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
11424
|
-
type: "button",
|
|
11425
|
-
onClick: voice.onEnd,
|
|
11426
|
-
"data-testid": testIds?.endCall,
|
|
11427
|
-
title: voice.labels.end ?? "",
|
|
11428
|
-
"aria-label": voice.labels.end ?? "",
|
|
11429
|
-
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"),
|
|
11430
|
-
children: /* @__PURE__ */ jsx(PhoneOff, { className: "size-4" })
|
|
11431
|
-
}) : null
|
|
11432
|
-
]
|
|
11433
|
-
}) : null]
|
|
11434
|
-
})
|
|
11435
|
-
})
|
|
11436
|
-
]
|
|
11437
|
-
})
|
|
12053
|
+
voice ? /* @__PURE__ */ jsx(MicButton, {
|
|
12054
|
+
voice,
|
|
12055
|
+
testId: testIds?.mic,
|
|
12056
|
+
className: "wgp-ib"
|
|
12057
|
+
}) : null,
|
|
12058
|
+
draft.trim() ? /* @__PURE__ */ jsx("button", {
|
|
12059
|
+
type: "submit",
|
|
12060
|
+
"aria-label": labels.send,
|
|
12061
|
+
"data-testid": testIds?.send,
|
|
12062
|
+
disabled: composerDisabled,
|
|
12063
|
+
className: "wgp-ib wgp-send",
|
|
12064
|
+
children: /* @__PURE__ */ jsx(Send, { className: "rtl:-scale-x-100" })
|
|
12065
|
+
}) : null
|
|
11438
12066
|
]
|
|
11439
|
-
})
|
|
12067
|
+
}),
|
|
12068
|
+
attribution || privacyChoices ? /* @__PURE__ */ jsxs("p", {
|
|
12069
|
+
className: "wgp-foot",
|
|
12070
|
+
children: [attribution ? /* @__PURE__ */ jsx("a", {
|
|
12071
|
+
href: attribution.href,
|
|
12072
|
+
target: "_blank",
|
|
12073
|
+
rel: "noopener noreferrer",
|
|
12074
|
+
"data-testid": "widget-branding",
|
|
12075
|
+
style: BRAND_BADGE_PLAIN,
|
|
12076
|
+
children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
|
|
12077
|
+
}) : null, privacyChoices ? /* @__PURE__ */ jsx("button", {
|
|
12078
|
+
type: "button",
|
|
12079
|
+
onClick: privacyChoices.open,
|
|
12080
|
+
"data-testid": "widget-privacy-choices",
|
|
12081
|
+
children: privacyChoices.label
|
|
12082
|
+
}) : null]
|
|
12083
|
+
}) : null
|
|
11440
12084
|
]
|
|
11441
|
-
})
|
|
11442
|
-
|
|
11443
|
-
href: attribution.href,
|
|
11444
|
-
target: "_blank",
|
|
11445
|
-
rel: "noopener noreferrer",
|
|
11446
|
-
"data-testid": "widget-branding",
|
|
11447
|
-
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"),
|
|
11448
|
-
style: BRAND_BADGE_PLAIN,
|
|
11449
|
-
children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
|
|
11450
|
-
}) : null,
|
|
11451
|
-
privacyChoices ? /* @__PURE__ */ jsx("button", {
|
|
11452
|
-
type: "button",
|
|
11453
|
-
onClick: privacyChoices.open,
|
|
11454
|
-
"data-testid": "widget-privacy-choices",
|
|
11455
|
-
className: cn(FOOTER_PILL, "end-0 text-[var(--widget-foreground)] underline", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
|
|
11456
|
-
children: privacyChoices.label
|
|
11457
|
-
}) : null
|
|
11458
|
-
]
|
|
11459
|
-
})
|
|
11460
|
-
}),
|
|
11461
|
-
portalActive && /* @__PURE__ */ jsx("div", {
|
|
11462
|
-
"aria-hidden": true,
|
|
11463
|
-
className: cn("pointer-events-none fixed z-[55]", positionClasses(position)),
|
|
11464
|
-
children: /* @__PURE__ */ jsx("div", {
|
|
11465
|
-
className: "widget-portal size-16",
|
|
11466
|
-
children: /* @__PURE__ */ jsx(MorphingLoader, {
|
|
11467
|
-
size: "full",
|
|
11468
|
-
label: labels.open
|
|
11469
|
-
})
|
|
12085
|
+
})
|
|
12086
|
+
] })
|
|
11470
12087
|
})
|
|
11471
12088
|
}),
|
|
11472
12089
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -11764,7 +12381,7 @@ function positionFor(dock) {
|
|
|
11764
12381
|
const align = dock?.layout?.desktopAlign;
|
|
11765
12382
|
return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
|
|
11766
12383
|
}
|
|
11767
|
-
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 }) {
|
|
12384
|
+
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 }) {
|
|
11768
12385
|
const [restored] = useState(readOpen);
|
|
11769
12386
|
const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
|
|
11770
12387
|
const onShown = dock?.onShown;
|
|
@@ -11779,6 +12396,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11779
12396
|
const [position, setPosition] = useState(() => positionFor(dock));
|
|
11780
12397
|
const draggable = dock?.layout?.draggable !== false;
|
|
11781
12398
|
const launcherLabel = dock?.copy?.minimisedLabel?.trim();
|
|
12399
|
+
const agentName = dock?.identity?.name?.trim();
|
|
11782
12400
|
/**
|
|
11783
12401
|
* The host's voice bag, merged the same way `DockRenderer` merges it: the
|
|
11784
12402
|
* conversation derives the PHASE fields (`agentSpeaking`, `micOpen` …) and
|
|
@@ -11878,7 +12496,8 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11878
12496
|
*/
|
|
11879
12497
|
const handoffAt = turns.findLastIndex((t) => t.event === "handoff");
|
|
11880
12498
|
const promiseKept = view.status?.kind === "message" && view.status.key === "escalated_banner" && turns.slice(handoffAt + 1).some((t) => t.speaker === "agent" && t.text.trim() !== "");
|
|
11881
|
-
const
|
|
12499
|
+
const restatesPill = showMic && (callPhase === "connecting" || callPhase === "waiting" || callPhase === "live") && view.status?.kind === "message" && (view.status.key === "dock_listening" || view.status.key === "dock_thinking");
|
|
12500
|
+
const statusText = view.status === null || promiseKept || restatesPill ? void 0 : view.status.kind === "text" ? view.status.text : messages[view.status.key] ?? void 0;
|
|
11882
12501
|
const voice = showMic ? {
|
|
11883
12502
|
phase: callPhase,
|
|
11884
12503
|
onStart: onToggleMic,
|
|
@@ -11925,18 +12544,23 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11925
12544
|
})
|
|
11926
12545
|
})]
|
|
11927
12546
|
})] }) : null;
|
|
12547
|
+
const checkout = callHooks?.widgetEvents?.findLast((event) => event.type === "checkout");
|
|
12548
|
+
const published = dock?.identity?.avatar;
|
|
12549
|
+
const face = avatar ?? (isWidgetAvatar(published) ? published : void 0);
|
|
11928
12550
|
return /* @__PURE__ */ jsxs(ConciergeShell, {
|
|
11929
12551
|
open,
|
|
11930
12552
|
onOpenChange: setOpen,
|
|
11931
12553
|
...restored ? { focusOnOpen: false } : {},
|
|
11932
12554
|
state: view.avatar,
|
|
11933
12555
|
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
11934
|
-
...
|
|
12556
|
+
...face !== void 0 ? { avatar: face } : {},
|
|
11935
12557
|
...attribution !== void 0 ? { attribution } : {},
|
|
11936
12558
|
...privacyChoices !== void 0 ? { privacyChoices } : {},
|
|
11937
12559
|
launcher: view.launcher,
|
|
11938
12560
|
...view.handoff && operatorName !== void 0 ? { operatorName } : {},
|
|
11939
12561
|
launcherInitials: view.launcher.initials ? handoffInitials(operatorName) : "",
|
|
12562
|
+
...dock?.layout?.launcher !== void 0 ? { launcherVariant: dock.layout.launcher } : {},
|
|
12563
|
+
...agentName ? { agentName } : {},
|
|
11940
12564
|
typing: view.typing,
|
|
11941
12565
|
messageArrived: lastTurn?.speaker === "caller",
|
|
11942
12566
|
idPrefix: "widget",
|
|
@@ -11951,12 +12575,24 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11951
12575
|
open: messages.open,
|
|
11952
12576
|
close: messages.minimize,
|
|
11953
12577
|
dialog: messages.conversation,
|
|
12578
|
+
...agentName ? { title: agentName } : {},
|
|
11954
12579
|
composerPlaceholder: messages.type_placeholder,
|
|
11955
12580
|
send: messages.send,
|
|
11956
12581
|
move: messages.move,
|
|
11957
12582
|
...launcherLabel ? { launcher: launcherLabel } : {}
|
|
11958
12583
|
},
|
|
11959
12584
|
...voice !== void 0 ? { voice } : {},
|
|
12585
|
+
...voice !== void 0 ? { call: {
|
|
12586
|
+
state: view.state,
|
|
12587
|
+
callerSpeaking: voiceInput.callerSpeaking === true,
|
|
12588
|
+
turns,
|
|
12589
|
+
renderCards,
|
|
12590
|
+
suggestions,
|
|
12591
|
+
...callHooks?.sendText !== void 0 ? { onSay: callHooks.sendText } : {},
|
|
12592
|
+
...checkout !== void 0 ? { checkout } : {},
|
|
12593
|
+
...cart !== void 0 ? { cart: cart.lines } : {},
|
|
12594
|
+
messages
|
|
12595
|
+
} } : {},
|
|
11960
12596
|
composerLeading,
|
|
11961
12597
|
badge: statusText === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
11962
12598
|
"data-testid": "widget-status",
|
|
@@ -11964,7 +12600,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11964
12600
|
role: "status",
|
|
11965
12601
|
"aria-live": "polite"
|
|
11966
12602
|
} : {},
|
|
11967
|
-
className: "
|
|
12603
|
+
className: "m-0",
|
|
11968
12604
|
children: statusText
|
|
11969
12605
|
}),
|
|
11970
12606
|
testIds: {
|
|
@@ -11999,248 +12635,57 @@ function DockRenderer({ turns, lastTurn, operatorName, composing, onEndCall, voi
|
|
|
11999
12635
|
},
|
|
12000
12636
|
...dock,
|
|
12001
12637
|
voice: {
|
|
12002
|
-
...voice,
|
|
12003
|
-
...dock?.voice ?? {}
|
|
12004
|
-
},
|
|
12005
|
-
messages,
|
|
12006
|
-
locale,
|
|
12007
|
-
status: statusLine,
|
|
12008
|
-
...statusKind !== void 0 ? { statusKind } : {},
|
|
12009
|
-
...notice !== void 0 ? { notice } : {},
|
|
12010
|
-
escalated,
|
|
12011
|
-
...operatorName !== void 0 ? { operatorName } : {},
|
|
12012
|
-
...onEndCall !== void 0 ? { onEndCall } : {},
|
|
12013
|
-
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
12014
|
-
...attribution !== void 0 ? { attribution } : {},
|
|
12015
|
-
...privacyChoices !== void 0 ? { privacyChoices } : {},
|
|
12016
|
-
...curationHref ? { curationHref } : {},
|
|
12017
|
-
...productHref ? { productHref } : {},
|
|
12018
|
-
...navigate ? { navigate } : {},
|
|
12019
|
-
draft,
|
|
12020
|
-
onDraftChange,
|
|
12021
|
-
onSubmit: submit,
|
|
12022
|
-
revealSheet: showBasket && cart !== void 0 && cart.lines.length > 0 || attaching !== null || capturing,
|
|
12023
|
-
followKey: turns.reduce((n, turn) => n + 1 + turn.text.length + (turn.cards?.items.length ?? 0), 0) + (humanTyping ? 1 : 0),
|
|
12024
|
-
...onAttach ? { onAttach } : {},
|
|
12025
|
-
attachBusy: attaching !== null && !attaching.failed,
|
|
12026
|
-
...attachInput !== null ? { attachSlot: attachInput } : {},
|
|
12027
|
-
sheetExtra: extras,
|
|
12028
|
-
transcript,
|
|
12029
|
-
transcriptCount: turns.length,
|
|
12030
|
-
...lastTurn !== void 0 ? { lastTurn } : {},
|
|
12031
|
-
composing
|
|
12032
|
-
});
|
|
12033
|
-
}
|
|
12034
|
-
//#endregion
|
|
12035
|
-
//#region src/renderers.ts
|
|
12036
|
-
/**
|
|
12037
|
-
* The one module that names BOTH renderers — docs/CONCIERGE_GENERATIONS.md §3.
|
|
12038
|
-
*
|
|
12039
|
-
* `VoiceWidget` and `ConciergeWidget` (the npm components) resolve a missing
|
|
12040
|
-
* `renderer` here from `ui.generation`. The CDN entries never import this
|
|
12041
|
-
* file: `cdn/ui.ts` passes `DockRenderer` and `cdn/ui-widget.ts` passes
|
|
12042
|
-
* `ShellRenderer` to `ConciergeHost` directly, which is what keeps each chunk
|
|
12043
|
-
* to one renderer's code (rule 3 of §3: nothing under `widget/` is reachable
|
|
12044
|
-
* from `cdn/ui.ts`, and vice versa — the budget guard measures it).
|
|
12045
|
-
*
|
|
12046
|
-
* Absent ⇒ the dock. That is the npm components' compatibility default, not
|
|
12047
|
-
* the product's: the published config defaults to `widget`
|
|
12048
|
-
* (`widget-config-upcast.ts`), and `cdn/core.ts` reads it that way. A React
|
|
12049
|
-
* host that wants the widget says so.
|
|
12050
|
-
*/
|
|
12051
|
-
function rendererFor(generation) {
|
|
12052
|
-
return generation === "widget" ? ShellRenderer : DockRenderer;
|
|
12053
|
-
}
|
|
12054
|
-
//#endregion
|
|
12055
|
-
//#region src/widget-markdown.tsx
|
|
12056
|
-
/**
|
|
12057
|
-
* Only `http(s)` and `mailto` survive.
|
|
12058
|
-
*
|
|
12059
|
-
* A model can emit `[click here](javascript:…)` as easily as a real URL, and a
|
|
12060
|
-
* bare `href` would execute it on click. Anything else renders as plain text,
|
|
12061
|
-
* so a rejected link still shows its label rather than vanishing.
|
|
12062
|
-
*/
|
|
12063
|
-
function safeHref(raw) {
|
|
12064
|
-
const href = raw.trim();
|
|
12065
|
-
if (/^https?:\/\//i.test(href)) return href;
|
|
12066
|
-
if (/^mailto:[^\s]+@[^\s]+$/i.test(href)) return href;
|
|
12067
|
-
return null;
|
|
12068
|
-
}
|
|
12069
|
-
/**
|
|
12070
|
-
* The bidi embedding and isolate controls (U+202A-U+202E, U+2066-U+2069),
|
|
12071
|
-
* removed from what a bubble shows (SAA-436). A right-to-left override typed
|
|
12072
|
-
* into a message reverses the rest of it on screen ("exe.txt" spoofing); the
|
|
12073
|
-
* bubble's own `dir="auto"` and `unicode-bidi: isolate` already order real
|
|
12074
|
-
* mixed-direction text, so nothing legitimate needs them.
|
|
12075
|
-
*/
|
|
12076
|
-
function stripBidiControls(text) {
|
|
12077
|
-
return text.replace(/[\u202A-\u202E\u2066-\u2069]/g, "");
|
|
12078
|
-
}
|
|
12079
|
-
/**
|
|
12080
|
-
* Inline constructs, innermost-last.
|
|
12081
|
-
*
|
|
12082
|
-
* Code is matched FIRST and never recurses into its own body: `` `**not
|
|
12083
|
-
* bold**` `` is a literal in every Markdown dialect, and parsing emphasis
|
|
12084
|
-
* inside it is the classic way a renderer mangles a code sample.
|
|
12085
|
-
*/
|
|
12086
|
-
function parseInline(src) {
|
|
12087
|
-
const out = [];
|
|
12088
|
-
let rest = src;
|
|
12089
|
-
while (rest.length > 0) {
|
|
12090
|
-
const match = /`([^`]+)`|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|(?<!\*)\*(?!\s)([^*\n]+?)\*(?!\*)|(?<!_)_(?!\s)([^_\n]+?)_(?!_)|\[([^\]]*)\]\(([^)\s]+)\)|(https:\/\/[^\s<>"'`]*[^\s<>"'`.,;:!?)\]])/.exec(rest);
|
|
12091
|
-
if (!match || match.index === void 0) {
|
|
12092
|
-
out.push({
|
|
12093
|
-
kind: "text",
|
|
12094
|
-
text: rest
|
|
12095
|
-
});
|
|
12096
|
-
break;
|
|
12097
|
-
}
|
|
12098
|
-
if (match.index > 0) out.push({
|
|
12099
|
-
kind: "text",
|
|
12100
|
-
text: rest.slice(0, match.index)
|
|
12101
|
-
});
|
|
12102
|
-
const [full, code, boldStar, boldUnd, italStar, italUnd, linkText, linkHref, bare] = match;
|
|
12103
|
-
if (code !== void 0) out.push({
|
|
12104
|
-
kind: "code",
|
|
12105
|
-
text: code
|
|
12106
|
-
});
|
|
12107
|
-
else if (boldStar !== void 0 || boldUnd !== void 0) out.push({
|
|
12108
|
-
kind: "bold",
|
|
12109
|
-
children: parseInline(boldStar ?? boldUnd)
|
|
12110
|
-
});
|
|
12111
|
-
else if (italStar !== void 0 || italUnd !== void 0) out.push({
|
|
12112
|
-
kind: "italic",
|
|
12113
|
-
children: parseInline(italStar ?? italUnd)
|
|
12114
|
-
});
|
|
12115
|
-
else if (linkHref !== void 0) {
|
|
12116
|
-
const href = safeHref(linkHref);
|
|
12117
|
-
const children = parseInline(linkText ?? "").flatMap((n) => n.kind === "link" ? n.children : [n]);
|
|
12118
|
-
out.push(href ? {
|
|
12119
|
-
kind: "link",
|
|
12120
|
-
href,
|
|
12121
|
-
children
|
|
12122
|
-
} : {
|
|
12123
|
-
kind: "text",
|
|
12124
|
-
text: linkText ?? ""
|
|
12125
|
-
});
|
|
12126
|
-
} else if (bare !== void 0) out.push({
|
|
12127
|
-
kind: "link",
|
|
12128
|
-
href: bare,
|
|
12129
|
-
children: [{
|
|
12130
|
-
kind: "text",
|
|
12131
|
-
text: bare
|
|
12132
|
-
}]
|
|
12133
|
-
});
|
|
12134
|
-
rest = rest.slice(match.index + full.length);
|
|
12135
|
-
}
|
|
12136
|
-
return out.filter((n) => !(n.kind === "text" && n.text === ""));
|
|
12137
|
-
}
|
|
12138
|
-
function sameOrigin(href) {
|
|
12139
|
-
try {
|
|
12140
|
-
return new URL(href).origin === window.location.origin;
|
|
12141
|
-
} catch {
|
|
12142
|
-
return false;
|
|
12143
|
-
}
|
|
12144
|
-
}
|
|
12145
|
-
function renderInline(nodes, keyPrefix) {
|
|
12146
|
-
return nodes.map((node, i) => {
|
|
12147
|
-
const key = `${keyPrefix}-${i}`;
|
|
12148
|
-
switch (node.kind) {
|
|
12149
|
-
case "text": return /* @__PURE__ */ jsx(Fragment$1, { children: node.text }, key);
|
|
12150
|
-
case "bold": return /* @__PURE__ */ jsx("strong", { children: renderInline(node.children, key) }, key);
|
|
12151
|
-
case "italic": return /* @__PURE__ */ jsx("em", { children: renderInline(node.children, key) }, key);
|
|
12152
|
-
case "code": return /* @__PURE__ */ jsx("code", {
|
|
12153
|
-
className: "rounded bg-black/10 px-1 py-0.5 font-mono text-[0.85em]",
|
|
12154
|
-
children: node.text
|
|
12155
|
-
}, key);
|
|
12156
|
-
case "link": return /* @__PURE__ */ jsx("a", {
|
|
12157
|
-
href: node.href,
|
|
12158
|
-
...sameOrigin(node.href) ? {} : {
|
|
12159
|
-
target: "_blank",
|
|
12160
|
-
rel: "noopener noreferrer nofollow"
|
|
12161
|
-
},
|
|
12162
|
-
className: "underline underline-offset-2 [overflow-wrap:anywhere]",
|
|
12163
|
-
children: renderInline(node.children, key)
|
|
12164
|
-
}, key);
|
|
12165
|
-
}
|
|
12166
|
-
});
|
|
12167
|
-
}
|
|
12168
|
-
var BULLET = /^\s*[-*+]\s+(.*)$/;
|
|
12169
|
-
var ORDERED = /^\s*\d+[.)]\s+(.*)$/;
|
|
12170
|
-
/**
|
|
12171
|
-
* Group lines into blocks.
|
|
12172
|
-
*
|
|
12173
|
-
* A blank line always closes the current block; a list item closes a paragraph
|
|
12174
|
-
* and vice versa. That last rule is what fixes the reported bug — the model
|
|
12175
|
-
* writes its intro and its bullets with no blank line between them, so
|
|
12176
|
-
* splitting on blank lines alone left `intro - item - item` as one paragraph.
|
|
12177
|
-
*/
|
|
12178
|
-
function parseBlocks(markdown) {
|
|
12179
|
-
const blocks = [];
|
|
12180
|
-
let paragraph = [];
|
|
12181
|
-
let list = null;
|
|
12182
|
-
const flushParagraph = () => {
|
|
12183
|
-
if (paragraph.length > 0) blocks.push({
|
|
12184
|
-
kind: "paragraph",
|
|
12185
|
-
lines: paragraph
|
|
12186
|
-
});
|
|
12187
|
-
paragraph = [];
|
|
12188
|
-
};
|
|
12189
|
-
const flushList = () => {
|
|
12190
|
-
if (list) blocks.push({
|
|
12191
|
-
kind: "list",
|
|
12192
|
-
ordered: list.ordered,
|
|
12193
|
-
items: list.items
|
|
12194
|
-
});
|
|
12195
|
-
list = null;
|
|
12196
|
-
};
|
|
12197
|
-
for (const line of markdown.split("\n")) {
|
|
12198
|
-
if (line.trim() === "") {
|
|
12199
|
-
flushParagraph();
|
|
12200
|
-
flushList();
|
|
12201
|
-
continue;
|
|
12202
|
-
}
|
|
12203
|
-
const bullet = BULLET.exec(line);
|
|
12204
|
-
const ordered = bullet ? null : ORDERED.exec(line);
|
|
12205
|
-
if (bullet ?? ordered) {
|
|
12206
|
-
flushParagraph();
|
|
12207
|
-
const isOrdered = ordered !== null;
|
|
12208
|
-
const text = (bullet?.[1] ?? ordered?.[1] ?? "").trim();
|
|
12209
|
-
if (list && list.ordered !== isOrdered) flushList();
|
|
12210
|
-
list ??= {
|
|
12211
|
-
ordered: isOrdered,
|
|
12212
|
-
items: []
|
|
12213
|
-
};
|
|
12214
|
-
list.items.push(text);
|
|
12215
|
-
continue;
|
|
12216
|
-
}
|
|
12217
|
-
flushList();
|
|
12218
|
-
paragraph.push(line.trim());
|
|
12219
|
-
}
|
|
12220
|
-
flushParagraph();
|
|
12221
|
-
flushList();
|
|
12222
|
-
return blocks;
|
|
12638
|
+
...voice,
|
|
12639
|
+
...dock?.voice ?? {}
|
|
12640
|
+
},
|
|
12641
|
+
messages,
|
|
12642
|
+
locale,
|
|
12643
|
+
status: statusLine,
|
|
12644
|
+
...statusKind !== void 0 ? { statusKind } : {},
|
|
12645
|
+
...notice !== void 0 ? { notice } : {},
|
|
12646
|
+
escalated,
|
|
12647
|
+
...operatorName !== void 0 ? { operatorName } : {},
|
|
12648
|
+
...onEndCall !== void 0 ? { onEndCall } : {},
|
|
12649
|
+
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
12650
|
+
...attribution !== void 0 ? { attribution } : {},
|
|
12651
|
+
...privacyChoices !== void 0 ? { privacyChoices } : {},
|
|
12652
|
+
...curationHref ? { curationHref } : {},
|
|
12653
|
+
...productHref ? { productHref } : {},
|
|
12654
|
+
...navigate ? { navigate } : {},
|
|
12655
|
+
draft,
|
|
12656
|
+
onDraftChange,
|
|
12657
|
+
onSubmit: submit,
|
|
12658
|
+
revealSheet: showBasket && cart !== void 0 && cart.lines.length > 0 || attaching !== null || capturing,
|
|
12659
|
+
followKey: turns.reduce((n, turn) => n + 1 + turn.text.length + (turn.cards?.items.length ?? 0), 0) + (humanTyping ? 1 : 0),
|
|
12660
|
+
...onAttach ? { onAttach } : {},
|
|
12661
|
+
attachBusy: attaching !== null && !attaching.failed,
|
|
12662
|
+
...attachInput !== null ? { attachSlot: attachInput } : {},
|
|
12663
|
+
sheetExtra: extras,
|
|
12664
|
+
transcript,
|
|
12665
|
+
transcriptCount: turns.length,
|
|
12666
|
+
...lastTurn !== void 0 ? { lastTurn } : {},
|
|
12667
|
+
composing
|
|
12668
|
+
});
|
|
12223
12669
|
}
|
|
12670
|
+
//#endregion
|
|
12671
|
+
//#region src/renderers.ts
|
|
12224
12672
|
/**
|
|
12225
|
-
*
|
|
12673
|
+
* The one module that names BOTH renderers — docs/CONCIERGE_GENERATIONS.md §3.
|
|
12226
12674
|
*
|
|
12227
|
-
*
|
|
12228
|
-
*
|
|
12229
|
-
*
|
|
12230
|
-
*
|
|
12231
|
-
*
|
|
12675
|
+
* `VoiceWidget` and `ConciergeWidget` (the npm components) resolve a missing
|
|
12676
|
+
* `renderer` here from `ui.generation`. The CDN entries never import this
|
|
12677
|
+
* file: `cdn/ui.ts` passes `DockRenderer` and `cdn/ui-widget.ts` passes
|
|
12678
|
+
* `ShellRenderer` to `ConciergeHost` directly, which is what keeps each chunk
|
|
12679
|
+
* to one renderer's code (rule 3 of §3: nothing under `widget/` is reachable
|
|
12680
|
+
* from `cdn/ui.ts`, and vice versa — the budget guard measures it).
|
|
12681
|
+
*
|
|
12682
|
+
* Absent ⇒ the dock. That is the npm components' compatibility default, not
|
|
12683
|
+
* the product's: the published config defaults to `widget`
|
|
12684
|
+
* (`widget-config-upcast.ts`), and `cdn/core.ts` reads it that way. A React
|
|
12685
|
+
* host that wants the widget says so.
|
|
12232
12686
|
*/
|
|
12233
|
-
function
|
|
12234
|
-
return
|
|
12235
|
-
if (block.kind === "list") return /* @__PURE__ */ jsx(block.ordered ? "ol" : "ul", {
|
|
12236
|
-
className: `my-1 space-y-1 ps-4 ${block.ordered ? "list-decimal" : "list-disc"}`,
|
|
12237
|
-
children: block.items.map((item, j) => /* @__PURE__ */ jsx("li", { children: renderInline(parseInline(item), `b${i}-i${j}`) }, `b${i}-i${j}`))
|
|
12238
|
-
}, `b${i}`);
|
|
12239
|
-
return /* @__PURE__ */ jsx("p", {
|
|
12240
|
-
className: "[&:not(:first-child)]:mt-2",
|
|
12241
|
-
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}`))
|
|
12242
|
-
}, `b${i}`);
|
|
12243
|
-
});
|
|
12687
|
+
function rendererFor(generation) {
|
|
12688
|
+
return generation === "widget" ? ShellRenderer : DockRenderer;
|
|
12244
12689
|
}
|
|
12245
12690
|
//#endregion
|
|
12246
12691
|
//#region src/widget-cards.tsx
|
|
@@ -12326,6 +12771,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12326
12771
|
children: formatMoney(item.priceMinor, item.currency, locale)
|
|
12327
12772
|
}) : null,
|
|
12328
12773
|
item.reason ? /* @__PURE__ */ jsx("p", {
|
|
12774
|
+
"data-testid": "widget-card-reason",
|
|
12329
12775
|
className: "line-clamp-2 text-pretty text-xs text-[var(--widget-foreground-muted)] italic",
|
|
12330
12776
|
children: item.reason
|
|
12331
12777
|
}) : null
|
|
@@ -12680,112 +13126,6 @@ function CheckoutButton({ onCheckout, navigate, messages }) {
|
|
|
12680
13126
|
}) : null] });
|
|
12681
13127
|
}
|
|
12682
13128
|
//#endregion
|
|
12683
|
-
//#region ../widget-protocol/dist/text-direction.js
|
|
12684
|
-
/**
|
|
12685
|
-
* Base direction for a block of text whose language is the CONTENT's, not the
|
|
12686
|
-
* reader's. Pure, string-only and dependency-free: a STATIC import into the
|
|
12687
|
-
* chat bundle a shopper downloads, shared by the console (`apps/web`) and the
|
|
12688
|
-
* widget (`@saar-ai/web-widget`), which used to keep a hand copy each.
|
|
12689
|
-
*
|
|
12690
|
-
* It lives here rather than in `@wesence/i18n` because the widget's published
|
|
12691
|
-
* bundle may resolve no `@wesence/*` module at all (`docs/PACKAGE_DISTRIBUTION.md`,
|
|
12692
|
-
* enforced by `scripts/check-npm-bundle-provenance.mjs`), the same reason
|
|
12693
|
-
* `./money` lives here.
|
|
12694
|
-
*
|
|
12695
|
-
* ## Why the console's own direction is the wrong answer
|
|
12696
|
-
*
|
|
12697
|
-
* `<html dir>` is set from the operator's UI locale, and every element inherits
|
|
12698
|
-
* it. That is right for the chrome and wrong for a transcript: an
|
|
12699
|
-
* English-speaking agent reading an Arabic conversation would render each
|
|
12700
|
-
* message with an LTR base direction, and the Unicode bidirectional algorithm
|
|
12701
|
-
* would then lay out the runs in the wrong order and throw trailing punctuation
|
|
12702
|
-
* to the wrong end of the line.
|
|
12703
|
-
*
|
|
12704
|
-
* The failure is invisible to the person looking at it. An agent who cannot read
|
|
12705
|
-
* Arabic sees Arabic-looking text and moves on; the customer is the one who gets
|
|
12706
|
-
* quoted back a sentence that reads incorrectly. The reverse case is just as
|
|
12707
|
-
* real — an Arabic-speaking agent reading English conversations under an RTL
|
|
12708
|
-
* base.
|
|
12709
|
-
*
|
|
12710
|
-
* ## Mixed runs are the normal case here, not an edge case
|
|
12711
|
-
*
|
|
12712
|
-
* Verified against live recognition output: Arabic comes back as
|
|
12713
|
-
* `رقم الـ order هو 4471. Please check من فضلك.` and Hindi as
|
|
12714
|
-
* `मेरा order number 4471 है।`. Latin nouns inside a non-Latin sentence are what
|
|
12715
|
-
* this product's transcripts actually contain, so bidirectional layout is
|
|
12716
|
-
* exercised on ordinary traffic rather than by an unusual customer.
|
|
12717
|
-
*
|
|
12718
|
-
* ## `auto` is the floor, not the goal
|
|
12719
|
-
*
|
|
12720
|
-
* With a known language this returns a definite direction. Without one it
|
|
12721
|
-
* returns `auto`, which delegates to the browser's first-strong-character
|
|
12722
|
-
* heuristic — better than inheriting the chrome, but wrong for a message that
|
|
12723
|
-
* opens with an English word and continues in Arabic (`Please check من فضلك`).
|
|
12724
|
-
* The real fix is to persist the conversation's resolved locale and pass it in;
|
|
12725
|
-
* see the note in `Transcript`.
|
|
12726
|
-
*/
|
|
12727
|
-
/**
|
|
12728
|
-
* Languages written right-to-left. Keyed on the language subtag, so a region
|
|
12729
|
-
* never has to be enumerated.
|
|
12730
|
-
*
|
|
12731
|
-
* Beyond Arabic on purpose: Hebrew, Farsi, Urdu and Pashto are the scripts a CX
|
|
12732
|
-
* product in this region acquires next, and getting one wrong is the same silent
|
|
12733
|
-
* failure. Adding a language to the product must not also require remembering
|
|
12734
|
-
* this file.
|
|
12735
|
-
*/
|
|
12736
|
-
var RTL_LANGUAGES = new Set([
|
|
12737
|
-
"ar",
|
|
12738
|
-
"he",
|
|
12739
|
-
"iw",
|
|
12740
|
-
"fa",
|
|
12741
|
-
"ur",
|
|
12742
|
-
"ps",
|
|
12743
|
-
"sd",
|
|
12744
|
-
"ug",
|
|
12745
|
-
"yi",
|
|
12746
|
-
"dv"
|
|
12747
|
-
]);
|
|
12748
|
-
/** Known LTR languages this product targets, so a typo does not silently pass. */
|
|
12749
|
-
var KNOWN_LTR_LANGUAGES = new Set([
|
|
12750
|
-
"en",
|
|
12751
|
-
"hi",
|
|
12752
|
-
"es",
|
|
12753
|
-
"fr",
|
|
12754
|
-
"de",
|
|
12755
|
-
"pt",
|
|
12756
|
-
"it",
|
|
12757
|
-
"nl",
|
|
12758
|
-
"id",
|
|
12759
|
-
"ta",
|
|
12760
|
-
"te",
|
|
12761
|
-
"bn",
|
|
12762
|
-
"mr",
|
|
12763
|
-
"gu",
|
|
12764
|
-
"kn",
|
|
12765
|
-
"ml",
|
|
12766
|
-
"pa"
|
|
12767
|
-
]);
|
|
12768
|
-
/** A well-formed BCP-47-ish language subtag: two or three ASCII letters. */
|
|
12769
|
-
var LANGUAGE_SUBTAG = /^[a-z]{2,3}$/;
|
|
12770
|
-
/**
|
|
12771
|
-
* The base direction for text in `locale`.
|
|
12772
|
-
*
|
|
12773
|
-
* @param locale BCP-47 tag from stored conversation data — untyped by the time
|
|
12774
|
-
* it reaches here, so anything malformed resolves to `auto` rather than to a
|
|
12775
|
-
* guess.
|
|
12776
|
-
*/
|
|
12777
|
-
function textDirectionFor$1(locale) {
|
|
12778
|
-
if (locale === void 0 || locale === null || locale === "") return "auto";
|
|
12779
|
-
const language = locale.toLowerCase().split("-")[0] ?? "";
|
|
12780
|
-
if (!LANGUAGE_SUBTAG.test(language)) return "auto";
|
|
12781
|
-
if (RTL_LANGUAGES.has(language)) return "rtl";
|
|
12782
|
-
if (KNOWN_LTR_LANGUAGES.has(language)) return "ltr";
|
|
12783
|
-
return "auto";
|
|
12784
|
-
}
|
|
12785
|
-
//#endregion
|
|
12786
|
-
//#region src/text-direction.ts
|
|
12787
|
-
var textDirectionFor = textDirectionFor$1;
|
|
12788
|
-
//#endregion
|
|
12789
13129
|
//#region src/voice-widget.tsx
|
|
12790
13130
|
/**
|
|
12791
13131
|
* The "still composing" affordance, shown in the agent's own bubble from the
|
|
@@ -12906,7 +13246,7 @@ function TurnDeliveryStatus({ delivery, messages }) {
|
|
|
12906
13246
|
});
|
|
12907
13247
|
}
|
|
12908
13248
|
/** Kept in sync with `ATTACHMENT_IMAGE_CONTENT_TYPES` in `apps/api/src/conversations/attachment-limits.ts` — display-only, never a security decision on this side. */
|
|
12909
|
-
var INLINE_IMAGE_TYPES = new Set([
|
|
13249
|
+
var INLINE_IMAGE_TYPES = /* @__PURE__ */ new Set([
|
|
12910
13250
|
"image/png",
|
|
12911
13251
|
"image/jpeg",
|
|
12912
13252
|
"image/webp",
|
|
@@ -13097,7 +13437,7 @@ function VoiceWidget({ renderer, generation, ...props }) {
|
|
|
13097
13437
|
});
|
|
13098
13438
|
}
|
|
13099
13439
|
/** `VoiceWidget` with the renderer decided — the component the CDN entries and `ConciergeHost` use. */
|
|
13100
|
-
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 }) {
|
|
13440
|
+
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 }) {
|
|
13101
13441
|
const [draft, setDraft] = useState("");
|
|
13102
13442
|
const [sending, setSending] = useState(false);
|
|
13103
13443
|
/** Roomy mode — see the expand control in the header. Collapses back on close, so a reopened widget starts small. */
|
|
@@ -13128,7 +13468,8 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13128
13468
|
filename: file.name,
|
|
13129
13469
|
failed: false
|
|
13130
13470
|
});
|
|
13131
|
-
|
|
13471
|
+
const okAttached = await onAttachFile(file);
|
|
13472
|
+
setAttaching(okAttached ? null : {
|
|
13132
13473
|
filename: file.name,
|
|
13133
13474
|
failed: true
|
|
13134
13475
|
});
|
|
@@ -13190,6 +13531,21 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13190
13531
|
* with two slices while §3.4 had a latest-exchange view (2026-09-11); since
|
|
13191
13532
|
* 2026-09-15 the visor always holds the whole log, so it renders one.
|
|
13192
13533
|
*/
|
|
13534
|
+
const renderCards = (cards) => /* @__PURE__ */ jsx(WidgetCardList, {
|
|
13535
|
+
cards,
|
|
13536
|
+
onAddToCart,
|
|
13537
|
+
onChooseOptions,
|
|
13538
|
+
chooseOptionsBusy,
|
|
13539
|
+
curationHref,
|
|
13540
|
+
productHref,
|
|
13541
|
+
navigate,
|
|
13542
|
+
locale,
|
|
13543
|
+
messages,
|
|
13544
|
+
roomy: false,
|
|
13545
|
+
...dock?.showPrice !== void 0 ? { showPrice: dock.showPrice } : {},
|
|
13546
|
+
...dock?.cardImageAspect !== void 0 ? { imageAspect: dock.cardImageAspect } : {}
|
|
13547
|
+
});
|
|
13548
|
+
const openers = suggestions ?? SUGGESTION_KEYS.map((key) => messages[key]);
|
|
13193
13549
|
const renderLog = (shown) => /* @__PURE__ */ jsxs("div", {
|
|
13194
13550
|
role: "log",
|
|
13195
13551
|
"aria-live": "polite",
|
|
@@ -13235,20 +13591,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13235
13591
|
}) : null,
|
|
13236
13592
|
turn.cards && turn.cards.items.length > 0 ? /* @__PURE__ */ jsx("div", {
|
|
13237
13593
|
className: "w-full",
|
|
13238
|
-
children:
|
|
13239
|
-
cards: turn.cards,
|
|
13240
|
-
onAddToCart,
|
|
13241
|
-
onChooseOptions,
|
|
13242
|
-
chooseOptionsBusy,
|
|
13243
|
-
curationHref,
|
|
13244
|
-
productHref,
|
|
13245
|
-
navigate,
|
|
13246
|
-
locale,
|
|
13247
|
-
messages,
|
|
13248
|
-
roomy: false,
|
|
13249
|
-
...dock?.showPrice !== void 0 ? { showPrice: dock.showPrice } : {},
|
|
13250
|
-
...dock?.cardImageAspect !== void 0 ? { imageAspect: dock.cardImageAspect } : {}
|
|
13251
|
-
})
|
|
13594
|
+
children: renderCards(turn.cards)
|
|
13252
13595
|
}) : null,
|
|
13253
13596
|
turn.delivery !== void 0 ? /* @__PURE__ */ jsx(TurnDeliveryStatus, {
|
|
13254
13597
|
delivery: turn.delivery,
|
|
@@ -13269,7 +13612,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13269
13612
|
"aria-label": messages.suggestions_label,
|
|
13270
13613
|
"data-testid": "widget-suggestions",
|
|
13271
13614
|
className: "flex flex-wrap gap-2 pt-1",
|
|
13272
|
-
children:
|
|
13615
|
+
children: openers.map((text) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
13273
13616
|
type: "button",
|
|
13274
13617
|
"data-testid": "widget-suggestion",
|
|
13275
13618
|
disabled: sending,
|
|
@@ -13418,6 +13761,9 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13418
13761
|
onAttach,
|
|
13419
13762
|
attachInput,
|
|
13420
13763
|
transcript: renderLog(turns),
|
|
13764
|
+
renderCards,
|
|
13765
|
+
suggestions: openers,
|
|
13766
|
+
call,
|
|
13421
13767
|
extras,
|
|
13422
13768
|
messages,
|
|
13423
13769
|
locale,
|
|
@@ -15431,7 +15777,7 @@ function useChatSession(options) {
|
|
|
15431
15777
|
let cancelled = false;
|
|
15432
15778
|
setConnection("connecting");
|
|
15433
15779
|
(async () => {
|
|
15434
|
-
const factory = socketFactory ?? (await import("./esm-
|
|
15780
|
+
const factory = socketFactory ?? (await import("./esm-5fDiLoFP.js")).io;
|
|
15435
15781
|
if (cancelled) return;
|
|
15436
15782
|
const socket = factory(`${socketUrl}${SOCKET_NAMESPACE}`, {
|
|
15437
15783
|
path: socketPath,
|
|
@@ -16289,17 +16635,124 @@ async function streamReply(args) {
|
|
|
16289
16635
|
case "read":
|
|
16290
16636
|
onRead();
|
|
16291
16637
|
break;
|
|
16292
|
-
case "done":
|
|
16293
|
-
|
|
16638
|
+
case "done": {
|
|
16639
|
+
const turnId = evt.data?.turnId ?? agentTurnId;
|
|
16640
|
+
onDone(turnId);
|
|
16294
16641
|
break;
|
|
16295
|
-
|
|
16296
|
-
|
|
16642
|
+
}
|
|
16643
|
+
case "error": {
|
|
16644
|
+
const message = evt.data?.message ?? "Something went wrong.";
|
|
16645
|
+
onError(message);
|
|
16297
16646
|
break;
|
|
16647
|
+
}
|
|
16298
16648
|
default: break;
|
|
16299
16649
|
}
|
|
16300
16650
|
}
|
|
16301
16651
|
}
|
|
16302
16652
|
//#endregion
|
|
16653
|
+
//#region src/spoken-transcript.ts
|
|
16654
|
+
/** The words of `provisional` after the `settled` prefix the caller heard. */
|
|
16655
|
+
function droppedWords(settled, provisional) {
|
|
16656
|
+
return provisional.trim().slice(settled.trim().length).split(/\s+/u).filter(Boolean).length;
|
|
16657
|
+
}
|
|
16658
|
+
/**
|
|
16659
|
+
* The turns the worker reported as cut short, from `turn.latency` frames,
|
|
16660
|
+
* added to `ids` (a fresh set when omitted) so a caller can accumulate them.
|
|
16661
|
+
*/
|
|
16662
|
+
function interruptedTurnIds(turns, ids = /* @__PURE__ */ new Set()) {
|
|
16663
|
+
for (const turn of turns) if (turn.interruptedBy !== void 0) ids.add(turn.turnId);
|
|
16664
|
+
return ids;
|
|
16665
|
+
}
|
|
16666
|
+
/**
|
|
16667
|
+
* So little that a bubble is noise: up to three words and under 24 characters.
|
|
16668
|
+
* A single "word" (a script written without spaces) must also be under
|
|
16669
|
+
* {@link NEGLIGIBLE_UNSPACED_MAX_CHARS}, or a cut-off sentence in Chinese or
|
|
16670
|
+
* Thai would count as one word.
|
|
16671
|
+
*/
|
|
16672
|
+
function isNegligibleText(raw) {
|
|
16673
|
+
const text = raw.trim();
|
|
16674
|
+
const words = text.split(/\s+/u).length;
|
|
16675
|
+
const cap = words > 1 ? 24 : 8;
|
|
16676
|
+
return words <= 3 && text.length < cap;
|
|
16677
|
+
}
|
|
16678
|
+
/**
|
|
16679
|
+
* Which settled agent lines were cut off by the caller. A line counts as cut
|
|
16680
|
+
* off when the hook saw it truncated, or when the worker reported its turn
|
|
16681
|
+
* interrupted and it is that turn's LAST agent line (`interruptedBy` covers
|
|
16682
|
+
* the turn; earlier lines of it finished). Fillers are never replies.
|
|
16683
|
+
*/
|
|
16684
|
+
function cutLineIndexes(lines, interrupted) {
|
|
16685
|
+
const cut = /* @__PURE__ */ new Set();
|
|
16686
|
+
const seen = /* @__PURE__ */ new Set();
|
|
16687
|
+
for (let i = lines.length - 1; i >= 0; i -= 1) {
|
|
16688
|
+
const line = lines[i];
|
|
16689
|
+
if (line.speaker !== "agent" || !line.final || line.filler) continue;
|
|
16690
|
+
const last = !seen.has(line.turnId);
|
|
16691
|
+
seen.add(line.turnId);
|
|
16692
|
+
if (line.truncated || last && interrupted.has(line.turnId)) cut.add(i);
|
|
16693
|
+
}
|
|
16694
|
+
return cut;
|
|
16695
|
+
}
|
|
16696
|
+
/** The cut-off lines ({@link cutLineIndexes}) that draw the "Interrupted" tag. */
|
|
16697
|
+
function taggedCutIndexes(lines, cut, interrupted) {
|
|
16698
|
+
return new Set([...cut].filter((i) => {
|
|
16699
|
+
const line = lines[i];
|
|
16700
|
+
return interrupted.has(line.turnId) || (line.dropped ?? 0) >= 3;
|
|
16701
|
+
}));
|
|
16702
|
+
}
|
|
16703
|
+
/** The cut-off lines ({@link cutLineIndexes}) with so little spoken that they draw nothing. */
|
|
16704
|
+
function negligibleLineIndexes(lines, cut) {
|
|
16705
|
+
return new Set([...cut].filter((i) => isNegligibleText(lines[i].text)));
|
|
16706
|
+
}
|
|
16707
|
+
/**
|
|
16708
|
+
* Which typed turns are the server's copy of a line the call is drawing live.
|
|
16709
|
+
*
|
|
16710
|
+
* Only turns the poll delivered (they carry `seq`) can be copies; a turn the
|
|
16711
|
+
* shopper typed is never hidden. A copy reaches the screen AFTER the line it
|
|
16712
|
+
* copies (the server stores a line once it is spoken, and the poll fetches it
|
|
16713
|
+
* later), so a live line only absorbs a copy stamped after it. That keeps a new
|
|
16714
|
+
* call's greeting from hiding the previous call's identical one. Each live line
|
|
16715
|
+
* absorbs at most one copy, so a caller who said "yes" twice keeps both answers
|
|
16716
|
+
* if the poll only has one of them.
|
|
16717
|
+
*
|
|
16718
|
+
* When a new call starts, `useVoiceSession` clears its transcript, the live
|
|
16719
|
+
* lines are gone, and the server's copies draw instead. That is how the
|
|
16720
|
+
* previous call stays on screen.
|
|
16721
|
+
*
|
|
16722
|
+
* @param typedStamps, spokenStamps `TurnOrderClock` stamps, index for index
|
|
16723
|
+
*/
|
|
16724
|
+
function echoedTurnIndexes(typed, typedStamps, spoken, spokenStamps) {
|
|
16725
|
+
const key = (line) => `${line.speaker}\u0000${line.text.trim().replace(/\s+/gu, " ")}`;
|
|
16726
|
+
const live = [];
|
|
16727
|
+
spoken.forEach((line, i) => {
|
|
16728
|
+
if (line.final) live.push([key(line), spokenStamps[i]]);
|
|
16729
|
+
});
|
|
16730
|
+
const echoed = /* @__PURE__ */ new Set();
|
|
16731
|
+
typed.forEach((turn, i) => {
|
|
16732
|
+
if (turn.seq === void 0 || turn.speaker === "event") return;
|
|
16733
|
+
const k = key(turn);
|
|
16734
|
+
const at = live.findIndex(([lk, stamp]) => lk === k && stamp < typedStamps[i]);
|
|
16735
|
+
if (at < 0) return;
|
|
16736
|
+
live.splice(at, 1);
|
|
16737
|
+
echoed.add(i);
|
|
16738
|
+
});
|
|
16739
|
+
return echoed;
|
|
16740
|
+
}
|
|
16741
|
+
/**
|
|
16742
|
+
* Where the "Call started" divider goes: just before the call's first line,
|
|
16743
|
+
* when something is already on screen above it. `null` means no divider.
|
|
16744
|
+
*
|
|
16745
|
+
* Stamps are integers from `TurnOrderClock`, so half a step before the first
|
|
16746
|
+
* line sorts the divider between it and the row above it.
|
|
16747
|
+
*
|
|
16748
|
+
* @param spoken this call's rows, @param others every other row on screen
|
|
16749
|
+
*/
|
|
16750
|
+
function callStartStamp(spoken, others) {
|
|
16751
|
+
if (spoken.length === 0) return null;
|
|
16752
|
+
const first = Math.min(...spoken.map((row) => row.stamp));
|
|
16753
|
+
return others.some((row) => row.stamp < first) ? first - .5 : null;
|
|
16754
|
+
}
|
|
16755
|
+
//#endregion
|
|
16303
16756
|
//#region src/use-voice-session.ts
|
|
16304
16757
|
/**
|
|
16305
16758
|
* Loads the call's wire-protocol codec and validation schema — see the module
|
|
@@ -16311,7 +16764,7 @@ async function streamReply(args) {
|
|
|
16311
16764
|
* cache makes a second `start()` after `stop()` free).
|
|
16312
16765
|
*/
|
|
16313
16766
|
async function loadVoiceProtocol() {
|
|
16314
|
-
const [telemetry, chat] = await Promise.all([import("./telemetry-
|
|
16767
|
+
const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-DHMjOVms.js")]);
|
|
16315
16768
|
return {
|
|
16316
16769
|
decodeTelemetry: telemetry.decodeTelemetry,
|
|
16317
16770
|
encodeCallerText: telemetry.encodeCallerText,
|
|
@@ -16448,6 +16901,11 @@ function joinClauses(first, second) {
|
|
|
16448
16901
|
* what keeps a barge-in intact: both legs revise at once there, and each
|
|
16449
16902
|
* keeps its own line.
|
|
16450
16903
|
*/
|
|
16904
|
+
function isCutShort(settled, provisional) {
|
|
16905
|
+
const heard = settled.trim();
|
|
16906
|
+
const shown = provisional.trim();
|
|
16907
|
+
return heard !== shown && shown.startsWith(heard);
|
|
16908
|
+
}
|
|
16451
16909
|
function coalesceTranscript(lines, line) {
|
|
16452
16910
|
const at = lines.findLastIndex((existing) => existing.speaker === line.speaker);
|
|
16453
16911
|
const open = at >= 0 ? lines[at] : void 0;
|
|
@@ -16455,6 +16913,10 @@ function coalesceTranscript(lines, line) {
|
|
|
16455
16913
|
const revised = line.speaker === "agent" && !line.final && line.cumulative !== true ? {
|
|
16456
16914
|
...line,
|
|
16457
16915
|
text: open.text.length >= MAX_AGENT_LINE_CHARS ? open.text : joinClauses(open.text, line.text)
|
|
16916
|
+
} : line.speaker === "agent" && line.final && isCutShort(line.text, open.text) ? {
|
|
16917
|
+
...line,
|
|
16918
|
+
truncated: true,
|
|
16919
|
+
dropped: droppedWords(line.text, open.text)
|
|
16458
16920
|
} : line;
|
|
16459
16921
|
return [
|
|
16460
16922
|
...lines.slice(0, at),
|
|
@@ -16587,7 +17049,8 @@ function createWidgetVoiceTokenFetcher(options) {
|
|
|
16587
17049
|
return async function fetchWidgetVoiceToken(tuning) {
|
|
16588
17050
|
const expiryMs = decodeJwtExpiryMs(options.chatToken);
|
|
16589
17051
|
if (expiryMs !== null && expiryMs <= Date.now()) throw new Error(SESSION_EXPIRED_MESSAGE);
|
|
16590
|
-
const
|
|
17052
|
+
const url = `${base}/voice/token?embedKey=${encodeURIComponent(options.embedKey)}`;
|
|
17053
|
+
const res = await fetchImpl(url, {
|
|
16591
17054
|
method: "POST",
|
|
16592
17055
|
cache: "no-store",
|
|
16593
17056
|
headers: {
|
|
@@ -16604,7 +17067,7 @@ function createWidgetVoiceTokenFetcher(options) {
|
|
|
16604
17067
|
};
|
|
16605
17068
|
}
|
|
16606
17069
|
async function defaultCreateRoom() {
|
|
16607
|
-
const { Room } = await import("./livekit-client.esm-
|
|
17070
|
+
const { Room } = await import("./livekit-client.esm-BSWImnve.js");
|
|
16608
17071
|
return new Room({
|
|
16609
17072
|
adaptiveStream: true,
|
|
16610
17073
|
dynacast: true
|
|
@@ -16678,6 +17141,7 @@ function useVoiceSession(options = {}) {
|
|
|
16678
17141
|
const agentLevelRef = useRef(0);
|
|
16679
17142
|
const [turns, setTurns] = useState([]);
|
|
16680
17143
|
const [transcript, setTranscript] = useState([]);
|
|
17144
|
+
const [callEpoch, setCallEpoch] = useState(0);
|
|
16681
17145
|
const [costs, setCosts] = useState([]);
|
|
16682
17146
|
/**
|
|
16683
17147
|
* What the concierge's tools put on screen this call — cards, a checkout
|
|
@@ -16733,6 +17197,7 @@ function useVoiceSession(options = {}) {
|
|
|
16733
17197
|
setEvents([]);
|
|
16734
17198
|
setTurns([]);
|
|
16735
17199
|
setTranscript([]);
|
|
17200
|
+
setCallEpoch((epoch) => epoch + 1);
|
|
16736
17201
|
setCosts([]);
|
|
16737
17202
|
setWidgetEvents([]);
|
|
16738
17203
|
setConfig(null);
|
|
@@ -17078,6 +17543,7 @@ function useVoiceSession(options = {}) {
|
|
|
17078
17543
|
agentLevelRef,
|
|
17079
17544
|
turns,
|
|
17080
17545
|
transcript,
|
|
17546
|
+
callEpoch,
|
|
17081
17547
|
costs,
|
|
17082
17548
|
config,
|
|
17083
17549
|
start,
|
|
@@ -17092,6 +17558,151 @@ function useVoiceSession(options = {}) {
|
|
|
17092
17558
|
};
|
|
17093
17559
|
}
|
|
17094
17560
|
//#endregion
|
|
17561
|
+
//#region src/theme/widget-derive.ts
|
|
17562
|
+
/**
|
|
17563
|
+
* The widget generation's extra `--wgt-*` tokens (docs/DOCK_SPEC.md §9.2),
|
|
17564
|
+
* derived on top of the dock's eighteen. Separate from `derive.ts` so the dock
|
|
17565
|
+
* chunk does not carry tokens it never reads (bundle budget).
|
|
17566
|
+
*/
|
|
17567
|
+
var WIDGET_GEN_EXTRA_TOKENS = [
|
|
17568
|
+
"--wgt-panel-radius",
|
|
17569
|
+
"--wgt-card-lg-radius",
|
|
17570
|
+
"--wgt-btn-radius",
|
|
17571
|
+
"--wgt-chip-radius",
|
|
17572
|
+
"--wgt-bubble-radius",
|
|
17573
|
+
"--wgt-bubble-tail-radius",
|
|
17574
|
+
"--wgt-launcher-radius",
|
|
17575
|
+
"--wgt-text-2",
|
|
17576
|
+
"--wgt-surface-3",
|
|
17577
|
+
"--wgt-panel-surface",
|
|
17578
|
+
"--wgt-panel-filter",
|
|
17579
|
+
"--wgt-elevation",
|
|
17580
|
+
"--wgt-card-elevation",
|
|
17581
|
+
"--wgt-accent-ink",
|
|
17582
|
+
"--wgt-live"
|
|
17583
|
+
];
|
|
17584
|
+
/** Every token the widget generation reads: the dock's, then the extras. */
|
|
17585
|
+
var WIDGET_GEN_TOKENS = [...WIDGET_THEME_TOKENS, ...WIDGET_GEN_EXTRA_TOKENS];
|
|
17586
|
+
/**
|
|
17587
|
+
* px per `type.radius`, in the order of the radius tokens above: panel, card,
|
|
17588
|
+
* button, chip, bubble, bubble tail, launcher. `999` is "fully round", a
|
|
17589
|
+
* length the browser clamps to half the box.
|
|
17590
|
+
*/
|
|
17591
|
+
var RADII = {
|
|
17592
|
+
square: [
|
|
17593
|
+
4,
|
|
17594
|
+
2,
|
|
17595
|
+
2,
|
|
17596
|
+
2,
|
|
17597
|
+
2,
|
|
17598
|
+
2,
|
|
17599
|
+
4
|
|
17600
|
+
],
|
|
17601
|
+
soft: [
|
|
17602
|
+
16,
|
|
17603
|
+
12,
|
|
17604
|
+
10,
|
|
17605
|
+
10,
|
|
17606
|
+
16,
|
|
17607
|
+
4,
|
|
17608
|
+
14
|
|
17609
|
+
],
|
|
17610
|
+
round: [
|
|
17611
|
+
24,
|
|
17612
|
+
18,
|
|
17613
|
+
999,
|
|
17614
|
+
999,
|
|
17615
|
+
20,
|
|
17616
|
+
6,
|
|
17617
|
+
999
|
|
17618
|
+
],
|
|
17619
|
+
pill: [
|
|
17620
|
+
28,
|
|
17621
|
+
20,
|
|
17622
|
+
999,
|
|
17623
|
+
999,
|
|
17624
|
+
20,
|
|
17625
|
+
6,
|
|
17626
|
+
999
|
|
17627
|
+
]
|
|
17628
|
+
};
|
|
17629
|
+
/** Secondary text sits this far from the text toward the surface, before the readability walk. */
|
|
17630
|
+
var TEXT_2_MIX = .2;
|
|
17631
|
+
/** The quiet fill is one step deeper than `--wgt-surface-2` (6 %). */
|
|
17632
|
+
var SURFACE_3_MIX = .1;
|
|
17633
|
+
/** `color.glass`: the panel's surface alpha; `widget-derive.test.ts` measures text over black and white pages. */
|
|
17634
|
+
var PANEL_GLASS_ALPHA = .8;
|
|
17635
|
+
var PANEL_GLASS_FILTER = "blur(24px) saturate(1.6)";
|
|
17636
|
+
/** [panel, card] shadows for a light surface, then for a dark one. */
|
|
17637
|
+
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)"]];
|
|
17638
|
+
/** Secondary text: walked back toward the text until it clears the 4.5:1 floor. */
|
|
17639
|
+
function deriveText2(text, surface) {
|
|
17640
|
+
for (let t = TEXT_2_MIX; t > 0; t = Number((t - .05).toFixed(2))) {
|
|
17641
|
+
const candidate = mixToward(text, surface, t);
|
|
17642
|
+
if (contrastRatio(candidate, surface) >= 4.5) return candidate;
|
|
17643
|
+
}
|
|
17644
|
+
return text;
|
|
17645
|
+
}
|
|
17646
|
+
function extend(base, type, glass) {
|
|
17647
|
+
const surface = base["--wgt-surface"];
|
|
17648
|
+
const text = base["--wgt-text"];
|
|
17649
|
+
const values = [
|
|
17650
|
+
...RADII[type.radius].map((n) => `${n}px`),
|
|
17651
|
+
deriveText2(text, surface),
|
|
17652
|
+
mixToward(surface, text, SURFACE_3_MIX),
|
|
17653
|
+
glass ? withAlpha(surface, PANEL_GLASS_ALPHA) : surface,
|
|
17654
|
+
glass ? PANEL_GLASS_FILTER : "none",
|
|
17655
|
+
...ELEVATION[hexToOklch(surface).L >= .5 ? 0 : 1],
|
|
17656
|
+
deriveRing(base["--wgt-primary"], surface, TEXT_CONTRAST_MIN),
|
|
17657
|
+
LIVE_COLOR
|
|
17658
|
+
];
|
|
17659
|
+
const out = { ...base };
|
|
17660
|
+
WIDGET_GEN_EXTRA_TOKENS.forEach((token, i) => out[token] = values[i]);
|
|
17661
|
+
return out;
|
|
17662
|
+
}
|
|
17663
|
+
/**
|
|
17664
|
+
* Every `--wgt-*` token the widget generation reads, from the published
|
|
17665
|
+
* `color` + `type` groups: {@link deriveTheme}'s eighteen plus the extras,
|
|
17666
|
+
* per block, with the same tone rules. Pure, and throws on the same inputs.
|
|
17667
|
+
*/
|
|
17668
|
+
function deriveWidgetTheme(color, type) {
|
|
17669
|
+
const base = deriveTheme(color, type);
|
|
17670
|
+
const glass = color.glass === true;
|
|
17671
|
+
return {
|
|
17672
|
+
light: extend(base.light, type, glass),
|
|
17673
|
+
...base.dark ? { dark: extend(base.dark, type, glass) } : {}
|
|
17674
|
+
};
|
|
17675
|
+
}
|
|
17676
|
+
//#endregion
|
|
17677
|
+
//#region src/theme/widget-theme-scope.tsx
|
|
17678
|
+
var DEFAULT_COLOR = {
|
|
17679
|
+
primary: "#111827",
|
|
17680
|
+
tone: "light"
|
|
17681
|
+
};
|
|
17682
|
+
var DEFAULT_TYPE = {
|
|
17683
|
+
font: "inherit",
|
|
17684
|
+
radius: "round",
|
|
17685
|
+
caps: "none"
|
|
17686
|
+
};
|
|
17687
|
+
/**
|
|
17688
|
+
* Puts the tenant's `--wgt-*` tokens (docs/DOCK_SPEC.md §9.2) on the widget
|
|
17689
|
+
* generation for every mount without a `core` stage (docs/CONCIERGE_GENERATIONS.md
|
|
17690
|
+
* §3.4). A scoped stylesheet rather than inline style so `tone: 'auto'` can carry
|
|
17691
|
+
* its `prefers-color-scheme` query. Every value comes out of `deriveWidgetTheme`.
|
|
17692
|
+
*/
|
|
17693
|
+
function WidgetThemeScope({ color = DEFAULT_COLOR, type = DEFAULT_TYPE, children }) {
|
|
17694
|
+
const id = useId();
|
|
17695
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
17696
|
+
"data-wgt-scope": id,
|
|
17697
|
+
style: { display: "contents" },
|
|
17698
|
+
children: [/* @__PURE__ */ jsx("style", { dangerouslySetInnerHTML: { __html: useMemo(() => scopedThemeCss(deriveWidgetTheme(color, type), `[data-wgt-scope="${id}"]`, WIDGET_GEN_TOKENS), [
|
|
17699
|
+
color,
|
|
17700
|
+
type,
|
|
17701
|
+
id
|
|
17702
|
+
]) } }), children]
|
|
17703
|
+
});
|
|
17704
|
+
}
|
|
17705
|
+
//#endregion
|
|
17095
17706
|
//#region ../widget-bridge/dist/page-context.js
|
|
17096
17707
|
function clampId(value, max) {
|
|
17097
17708
|
if (typeof value !== "string") return void 0;
|
|
@@ -17270,7 +17881,7 @@ var HEADS = {
|
|
|
17270
17881
|
articles: "article"
|
|
17271
17882
|
};
|
|
17272
17883
|
/** Heads whose bare form is a listing page, not an instance of the kind (`/blog`, `/case-studies`, `/customers`). */
|
|
17273
|
-
var NEEDS_CHILD = new Set([
|
|
17884
|
+
var NEEDS_CHILD = /* @__PURE__ */ new Set([
|
|
17274
17885
|
"blog",
|
|
17275
17886
|
"articles",
|
|
17276
17887
|
"case-studies",
|
|
@@ -17280,7 +17891,7 @@ var NEEDS_CHILD = new Set([
|
|
|
17280
17891
|
/** `en`, `fr`, `en-gb`: the locale prefix an i18n router or Shopify Markets puts in front of a path. */
|
|
17281
17892
|
var LOCALE_SEGMENT = /^[a-z]{2}(?:-[a-z]{2})?$/u;
|
|
17282
17893
|
/** Slugs under `/customers/` that are account pages, never a case study. */
|
|
17283
|
-
var ACCOUNT_SLUGS = new Set([
|
|
17894
|
+
var ACCOUNT_SLUGS = /* @__PURE__ */ new Set([
|
|
17284
17895
|
"login",
|
|
17285
17896
|
"logout",
|
|
17286
17897
|
"register",
|
|
@@ -18145,10 +18756,28 @@ function deriveCallPhase(voice) {
|
|
|
18145
18756
|
* when the caller did not. See `renderers.ts` for why they are two functions.
|
|
18146
18757
|
*/
|
|
18147
18758
|
function ConciergeWidget({ renderer, ...props }) {
|
|
18148
|
-
|
|
18759
|
+
const host = /* @__PURE__ */ jsx(ConciergeHost, {
|
|
18149
18760
|
...props,
|
|
18150
18761
|
renderer: renderer ?? rendererFor(props.generation)
|
|
18151
18762
|
});
|
|
18763
|
+
const brand = useMemo(() => brandColor(props.brandPrimary), [props.brandPrimary]);
|
|
18764
|
+
return props.generation === "widget" ? /* @__PURE__ */ jsx(WidgetThemeScope, {
|
|
18765
|
+
color: props.color ?? brand,
|
|
18766
|
+
type: props.type,
|
|
18767
|
+
children: host
|
|
18768
|
+
}) : host;
|
|
18769
|
+
}
|
|
18770
|
+
function brandColor(primary) {
|
|
18771
|
+
if (primary === void 0) return void 0;
|
|
18772
|
+
try {
|
|
18773
|
+
parseHex(primary);
|
|
18774
|
+
} catch {
|
|
18775
|
+
return;
|
|
18776
|
+
}
|
|
18777
|
+
return {
|
|
18778
|
+
primary,
|
|
18779
|
+
tone: "light"
|
|
18780
|
+
};
|
|
18152
18781
|
}
|
|
18153
18782
|
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 }) {
|
|
18154
18783
|
/**
|
|
@@ -18889,7 +19518,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
18889
19518
|
if (!inCallRef.current) await waitForTypedTurnToLand();
|
|
18890
19519
|
if (!actLiveRef.current || typeof window === "undefined") return;
|
|
18891
19520
|
try {
|
|
18892
|
-
const { fillHostForm } = await import("./form-fill-dom-
|
|
19521
|
+
const { fillHostForm } = await import("./form-fill-dom-D4ZMwxX1.js");
|
|
18893
19522
|
if (actLiveRef.current) fillHostForm(window.document, event);
|
|
18894
19523
|
} catch {}
|
|
18895
19524
|
return;
|
|
@@ -19404,6 +20033,13 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19404
20033
|
*/
|
|
19405
20034
|
const orderRef = useRef(null);
|
|
19406
20035
|
orderRef.current ??= new TurnOrderClock();
|
|
20036
|
+
const callRef = useRef(null);
|
|
20037
|
+
const pastCallsRef = useRef({
|
|
20038
|
+
lines: [],
|
|
20039
|
+
stamps: [],
|
|
20040
|
+
rows: []
|
|
20041
|
+
});
|
|
20042
|
+
const interruptedRef = useRef(/* @__PURE__ */ new Set());
|
|
19407
20043
|
const widgetTurns = useMemo(() => {
|
|
19408
20044
|
const mapTypedTurn = (turn) => ({
|
|
19409
20045
|
speaker: turn.speaker,
|
|
@@ -19418,19 +20054,32 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19418
20054
|
});
|
|
19419
20055
|
if (!voiceEnabled) return session.turns.map(mapTypedTurn);
|
|
19420
20056
|
const order = orderRef.current;
|
|
20057
|
+
const lines = voice.transcript;
|
|
20058
|
+
const epoch = voice.callEpoch;
|
|
20059
|
+
const past = pastCallsRef.current;
|
|
20060
|
+
const last = callRef.current;
|
|
20061
|
+
if (last !== null && last.epoch !== epoch) {
|
|
20062
|
+
past.lines.push(...last.lines);
|
|
20063
|
+
past.stamps.push(...last.stamps);
|
|
20064
|
+
past.rows.push(...last.rows.filter((row) => row.turn.final));
|
|
20065
|
+
}
|
|
20066
|
+
interruptedTurnIds(voice.turns, interruptedRef.current);
|
|
19421
20067
|
const typedStamps = order.stampTyped(session.turns);
|
|
19422
|
-
const
|
|
20068
|
+
const spokenStamps = order.stampSpoken(lines);
|
|
20069
|
+
const echoed = echoedTurnIndexes(session.turns, typedStamps, [...past.lines, ...lines], [...past.stamps, ...spokenStamps]);
|
|
20070
|
+
const typed = session.turns.flatMap((turn, i) => echoed.has(i) ? [] : [{
|
|
19423
20071
|
stamp: typedStamps[i],
|
|
19424
20072
|
turn: mapTypedTurn(turn)
|
|
19425
|
-
})
|
|
19426
|
-
const lines = voice.transcript;
|
|
19427
|
-
const spokenStamps = order.stampSpoken(lines);
|
|
20073
|
+
}]);
|
|
19428
20074
|
const lastIndexBySpeaker = /* @__PURE__ */ new Map();
|
|
19429
20075
|
lines.forEach((l, i) => lastIndexBySpeaker.set(l.speaker, i));
|
|
20076
|
+
const cut = cutLineIndexes(lines, interruptedRef.current);
|
|
20077
|
+
const negligible = negligibleLineIndexes(lines, cut);
|
|
20078
|
+
const tagged = taggedCutIndexes(lines, cut, interruptedRef.current);
|
|
19430
20079
|
const visible = lines.map((line, i) => ({
|
|
19431
20080
|
line,
|
|
19432
20081
|
i
|
|
19433
|
-
})).filter(({ line, i }) => line.final || lastIndexBySpeaker.get(line.speaker) === i);
|
|
20082
|
+
})).filter(({ line, i }) => (line.final || lastIndexBySpeaker.get(line.speaker) === i) && !negligible.has(i));
|
|
19434
20083
|
/**
|
|
19435
20084
|
* Every stamped curation, gathered by the turn that raised it. Stamping
|
|
19436
20085
|
* happens HERE, over the whole list and on every render, because
|
|
@@ -19539,6 +20188,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19539
20188
|
locale: line.locale,
|
|
19540
20189
|
final: line.final,
|
|
19541
20190
|
...line.filler ? { filler: true } : {},
|
|
20191
|
+
...tagged.has(i) ? { cut: true } : {},
|
|
19542
20192
|
...bound === void 0 ? {} : { cards: {
|
|
19543
20193
|
...bound.curationId !== void 0 ? { curationId: bound.curationId } : {},
|
|
19544
20194
|
items: bound.items
|
|
@@ -19559,14 +20209,38 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19559
20209
|
}
|
|
19560
20210
|
}
|
|
19561
20211
|
}));
|
|
20212
|
+
const callStart = callStartStamp(spoken, [
|
|
20213
|
+
...typed,
|
|
20214
|
+
...rendered,
|
|
20215
|
+
...past.rows
|
|
20216
|
+
]);
|
|
20217
|
+
const rows = [...spoken, ...rendered];
|
|
20218
|
+
if (callStart !== null) rows.push({
|
|
20219
|
+
stamp: callStart,
|
|
20220
|
+
turn: {
|
|
20221
|
+
speaker: "event",
|
|
20222
|
+
event: "call_started",
|
|
20223
|
+
text: "",
|
|
20224
|
+
locale,
|
|
20225
|
+
final: true
|
|
20226
|
+
}
|
|
20227
|
+
});
|
|
20228
|
+
callRef.current = {
|
|
20229
|
+
epoch,
|
|
20230
|
+
lines,
|
|
20231
|
+
stamps: spokenStamps,
|
|
20232
|
+
rows
|
|
20233
|
+
};
|
|
19562
20234
|
return [
|
|
19563
20235
|
...typed,
|
|
19564
|
-
...
|
|
19565
|
-
...
|
|
20236
|
+
...past.rows,
|
|
20237
|
+
...rows
|
|
19566
20238
|
].sort((a, b) => a.stamp - b.stamp).map((entry) => entry.turn);
|
|
19567
20239
|
}, [
|
|
19568
20240
|
session.turns,
|
|
19569
20241
|
voice.transcript,
|
|
20242
|
+
voice.callEpoch,
|
|
20243
|
+
voice.turns,
|
|
19570
20244
|
voice.widgetEvents,
|
|
19571
20245
|
voiceEnabled,
|
|
19572
20246
|
locale
|
|
@@ -19956,7 +20630,8 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19956
20630
|
onToggleMic,
|
|
19957
20631
|
...voiceEnabled ? {
|
|
19958
20632
|
onEndCall: () => void voice.stop(),
|
|
19959
|
-
callPhase
|
|
20633
|
+
callPhase,
|
|
20634
|
+
call: voice
|
|
19960
20635
|
} : {},
|
|
19961
20636
|
onSendText,
|
|
19962
20637
|
escalated,
|
|
@@ -19984,4 +20659,4 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19984
20659
|
});
|
|
19985
20660
|
}
|
|
19986
20661
|
//#endregion
|
|
19987
|
-
export {
|
|
20662
|
+
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 };
|