@saar-ai/web-widget 0.18.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{chat-DHMjOVms.js → chat-Bm4MPdY9.js} +25 -1
- package/dist/chunks/{form-fill-dom-D4ZMwxX1.js → form-fill-dom-Dxt-z0H0.js} +4 -0
- package/dist/chunks/{host-widget-BhtqtvaY.js → host-widget-kHzdanwT.js} +265 -72
- package/dist/concierge-shell.css +1 -1
- package/dist/dock/dock-sheet.d.ts.map +1 -1
- package/dist/form-fill/form-fill-dom.d.ts +5 -11
- package/dist/form-fill/form-fill-dom.d.ts.map +1 -1
- package/dist/generated/concierge-shell-css.d.ts.map +1 -1
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.js +14 -14
- package/dist/messages.d.ts +13 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/scroll-row.d.ts +29 -0
- package/dist/scroll-row.d.ts.map +1 -0
- package/dist/spoken-transcript.d.ts +2 -0
- package/dist/spoken-transcript.d.ts.map +1 -1
- package/dist/turn-order.d.ts +2 -1
- package/dist/turn-order.d.ts.map +1 -1
- package/dist/use-voice-session.d.ts.map +1 -1
- package/dist/widget/call-view.d.ts +32 -2
- package/dist/widget/call-view.d.ts.map +1 -1
- package/dist/widget/concierge-launcher.d.ts +6 -1
- package/dist/widget/concierge-launcher.d.ts.map +1 -1
- package/dist/widget/concierge-shell.d.ts +2 -0
- package/dist/widget/concierge-shell.d.ts.map +1 -1
- package/dist/widget/launcher-look.d.ts.map +1 -1
- package/dist/widget/mic-button.d.ts +4 -0
- package/dist/widget/mic-button.d.ts.map +1 -1
- package/dist/widget/shell-renderer.d.ts +1 -1
- package/dist/widget/shell-renderer.d.ts.map +1 -1
- package/dist/widget-cards.d.ts.map +1 -1
- package/dist/widget-cart-summary.d.ts.map +1 -1
- package/dist/widget.css +1 -1
- package/package.json +11 -7
- package/src/styles/call-view.css +13 -3
- package/src/styles/concierge-shell-entry.css +1 -0
- package/src/styles/concierge.css +3 -0
- package/src/styles/scroll-row.css +62 -0
- package/src/styles/tokens.css +1 -1
- package/src/styles/widget-entry.css +1 -0
|
@@ -4680,7 +4680,13 @@ var defaultWidgetMessages = {
|
|
|
4680
4680
|
voice_unavailable_escalated: "Voice is unavailable while you’re talking to a person",
|
|
4681
4681
|
choose_options: "Choose options",
|
|
4682
4682
|
choose_options_label: "Choose options for {title}",
|
|
4683
|
-
choose_options_after_call: "I’ll ask about options after the call"
|
|
4683
|
+
choose_options_after_call: "I’ll ask about options after the call",
|
|
4684
|
+
cards_label: "Recommended products",
|
|
4685
|
+
cards_slide: "{n} of {total}",
|
|
4686
|
+
cards_prev: "Previous products",
|
|
4687
|
+
cards_next: "Next products",
|
|
4688
|
+
cards_carousel: "carousel",
|
|
4689
|
+
cards_slide_role: "slide"
|
|
4684
4690
|
};
|
|
4685
4691
|
/**
|
|
4686
4692
|
* Interpolates `{token}` placeholders in a message template. Deliberately the
|
|
@@ -7599,6 +7605,7 @@ function DockSheet({ snap, onSnapChange, label, peekOnly, header, children, onDi
|
|
|
7599
7605
|
ref: bodyRef,
|
|
7600
7606
|
className: "wgt-sheet-body",
|
|
7601
7607
|
"data-testid": "widget-dock-sheet-body",
|
|
7608
|
+
tabIndex: 0,
|
|
7602
7609
|
onScroll,
|
|
7603
7610
|
children
|
|
7604
7611
|
})]
|
|
@@ -10574,6 +10581,7 @@ var LAUNCHER_MARK_SIZE = {
|
|
|
10574
10581
|
};
|
|
10575
10582
|
var LAUNCHER_SURFACE = "var(--wgt-panel-surface,var(--widget-card,#fff))";
|
|
10576
10583
|
var LAUNCHER_TEXT = "var(--wgt-text,var(--widget-foreground,#1c1618))";
|
|
10584
|
+
/** The theme's muted text, else the shared role (dark in a `.dark` host), else `deriveWidgetTheme`'s default. */
|
|
10577
10585
|
var MUTED = "var(--wgt-text-muted,var(--widget-foreground-muted,rgba(28,22,24,.73)))";
|
|
10578
10586
|
var LAUNCHER_ELEVATION = "var(--wgt-elevation,0 0 0 1px rgba(0,0,0,.06),0 24px 60px -22px rgba(0,0,0,.32))";
|
|
10579
10587
|
/** The live-call dot, and `--wgt-live`'s value: constant, so it reads as "live" on every theme. */
|
|
@@ -10699,7 +10707,7 @@ var QUIET = {
|
|
|
10699
10707
|
badge: false,
|
|
10700
10708
|
initials: false
|
|
10701
10709
|
};
|
|
10702
|
-
function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "", launcher = DEFAULT_LAUNCHER_VARIANT, agentName, subLabel, callLabel }) {
|
|
10710
|
+
function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChange, onOpen, hidden, id, testId, avatar = "orb", spec = QUIET, initials = "", launcher = DEFAULT_LAUNCHER_VARIANT, agentName, subLabel, callLabel, callSrLabel }) {
|
|
10703
10711
|
const rootRef = useRef(null);
|
|
10704
10712
|
/** Pixel offset while a drag is in flight; `null` when it is not. */
|
|
10705
10713
|
const [drag, setDrag] = useState(null);
|
|
@@ -10787,7 +10795,7 @@ function ConciergeLauncher({ label, srLabel, moveLabel, position, onPositionChan
|
|
|
10787
10795
|
const round = launcher === "round";
|
|
10788
10796
|
const sub = callLabel ?? subLabel;
|
|
10789
10797
|
const showText = !round && (label !== void 0 || sub !== void 0);
|
|
10790
|
-
const ariaLabel = round || label === void 0 ? [srLabel, callLabel].filter(Boolean).join("
|
|
10798
|
+
const ariaLabel = round || label === void 0 ? [srLabel, callSrLabel ?? callLabel].filter(Boolean).join(", ") : callSrLabel && `${label}, ${callSrLabel}`;
|
|
10791
10799
|
return /* @__PURE__ */ jsxs("div", {
|
|
10792
10800
|
ref: rootRef,
|
|
10793
10801
|
id,
|
|
@@ -11216,6 +11224,84 @@ function WidgetMarkdown({ text }) {
|
|
|
11216
11224
|
});
|
|
11217
11225
|
}
|
|
11218
11226
|
//#endregion
|
|
11227
|
+
//#region src/scroll-row.tsx
|
|
11228
|
+
/**
|
|
11229
|
+
* Which way a horizontal row can still scroll: bit 1 back (towards
|
|
11230
|
+
* inline-start), bit 2 on (towards inline-end). `scrollLeft` runs negative in
|
|
11231
|
+
* RTL, so its magnitude is the distance from the start in both directions.
|
|
11232
|
+
*/
|
|
11233
|
+
function scrollEdges(el) {
|
|
11234
|
+
const x = Math.abs(el.scrollLeft);
|
|
11235
|
+
return (x > 1 ? 1 : 0) | (x < el.scrollWidth - el.clientWidth - 1 ? 2 : 0);
|
|
11236
|
+
}
|
|
11237
|
+
/**
|
|
11238
|
+
* Scrolls by one item and the gap after it (else the row's width), `dir`
|
|
11239
|
+
* physical: 1 is rightwards. Smoothness is the stylesheet's, so it honours
|
|
11240
|
+
* reduced motion.
|
|
11241
|
+
*/
|
|
11242
|
+
function nudge(el, dir) {
|
|
11243
|
+
const [a, b] = el.children;
|
|
11244
|
+
el.scrollBy({ left: dir * (a && b && Math.abs(b.offsetLeft - a.offsetLeft) || el.clientWidth) });
|
|
11245
|
+
}
|
|
11246
|
+
var CHEVRON = /* @__PURE__ */ jsx("svg", {
|
|
11247
|
+
viewBox: "0 0 24 24",
|
|
11248
|
+
"aria-hidden": "true",
|
|
11249
|
+
children: /* @__PURE__ */ jsx("path", { d: "m9 6 6 6-6 6" })
|
|
11250
|
+
});
|
|
11251
|
+
/**
|
|
11252
|
+
* A horizontal scroller a keyboard and a mouse can both drive: the row takes
|
|
11253
|
+
* focus and moves one item per Left/Right, and `arrows` are previous/next
|
|
11254
|
+
* buttons that exist only while there is somewhere to go. Spread `row` on
|
|
11255
|
+
* the scrolling element and render it, with `arrows`, inside `.wsr`
|
|
11256
|
+
* (`styles/scroll-row.css`, which also hides the buttons on touch screens).
|
|
11257
|
+
*
|
|
11258
|
+
* Measured on mount, on scroll, when `count` (the number of items) changes and
|
|
11259
|
+
* when the row is resized, never on an unrelated render: a streamed reply
|
|
11260
|
+
* re-renders on every token, and a read of the row's scroll width forces
|
|
11261
|
+
* layout of rows `content-visibility: auto` skipped.
|
|
11262
|
+
*/
|
|
11263
|
+
function useScrollRow(prev, next, count) {
|
|
11264
|
+
const ref = useRef(null);
|
|
11265
|
+
const [edges, setEdges] = useState(0);
|
|
11266
|
+
const measure = () => {
|
|
11267
|
+
if (ref.current) setEdges(scrollEdges(ref.current));
|
|
11268
|
+
};
|
|
11269
|
+
useEffect(() => {
|
|
11270
|
+
measure();
|
|
11271
|
+
const el = ref.current;
|
|
11272
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
11273
|
+
const observer = new ResizeObserver(measure);
|
|
11274
|
+
observer.observe(el);
|
|
11275
|
+
return () => observer.disconnect();
|
|
11276
|
+
}, [count]);
|
|
11277
|
+
const button = (dir, label, bit) => /* @__PURE__ */ jsx("button", {
|
|
11278
|
+
type: "button",
|
|
11279
|
+
className: "wsr-b",
|
|
11280
|
+
"data-n": dir > 0 ? "" : void 0,
|
|
11281
|
+
"aria-label": label,
|
|
11282
|
+
hidden: !(edges & bit),
|
|
11283
|
+
onClick: () => {
|
|
11284
|
+
const el = ref.current;
|
|
11285
|
+
if (el) nudge(el, getComputedStyle(el).direction === "rtl" ? -dir : dir);
|
|
11286
|
+
},
|
|
11287
|
+
children: CHEVRON
|
|
11288
|
+
});
|
|
11289
|
+
return {
|
|
11290
|
+
row: {
|
|
11291
|
+
ref,
|
|
11292
|
+
tabIndex: 0,
|
|
11293
|
+
onScroll: measure,
|
|
11294
|
+
onKeyDown: (event) => {
|
|
11295
|
+
const dir = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
11296
|
+
if (!dir || event.target !== event.currentTarget) return;
|
|
11297
|
+
event.preventDefault();
|
|
11298
|
+
nudge(event.currentTarget, dir);
|
|
11299
|
+
}
|
|
11300
|
+
},
|
|
11301
|
+
arrows: /* @__PURE__ */ jsxs(Fragment, { children: [button(-1, prev, 1), button(1, next, 2)] })
|
|
11302
|
+
};
|
|
11303
|
+
}
|
|
11304
|
+
//#endregion
|
|
11219
11305
|
//#region src/widget/mic-button.tsx
|
|
11220
11306
|
/**
|
|
11221
11307
|
* What the microphone control means right now: start, mute or unmute, or,
|
|
@@ -11225,6 +11311,10 @@ function WidgetMarkdown({ text }) {
|
|
|
11225
11311
|
* and busy: one impatient press must not become a second call, or a mute of a
|
|
11226
11312
|
* call that does not exist yet. It reports no pressed state then, because
|
|
11227
11313
|
* there is no call yet to have muted.
|
|
11314
|
+
*
|
|
11315
|
+
* On a call it is a toggle: one name ("Mute") and `aria-pressed` for the
|
|
11316
|
+
* state. A name that flips to "Unmute" as well would be read as "Unmute,
|
|
11317
|
+
* pressed", which says the opposite of what is true.
|
|
11228
11318
|
*/
|
|
11229
11319
|
function micControl(voice) {
|
|
11230
11320
|
const connecting = voice.phase === "connecting";
|
|
@@ -11233,7 +11323,7 @@ function micControl(voice) {
|
|
|
11233
11323
|
const connectingLabel = voice.labels.connecting ?? defaultWidgetMessages.voice_state_connecting;
|
|
11234
11324
|
const muted = inCall && voice.muted === true;
|
|
11235
11325
|
return {
|
|
11236
|
-
label: unusable ? voice.labels.unavailable ?? voice.labels.start : connecting ? connectingLabel : inCall ?
|
|
11326
|
+
label: unusable ? voice.labels.unavailable ?? voice.labels.start : connecting ? connectingLabel : inCall ? voice.labels.mute ?? (voice.onToggleMute ? defaultWidgetMessages.mic_stop : voice.labels.start) : voice.labels.start,
|
|
11237
11327
|
onClick: connecting ? void 0 : inCall ? voice.onToggleMute ?? voice.onStart : voice.onStart,
|
|
11238
11328
|
disabled: unusable || connecting,
|
|
11239
11329
|
busy: connecting,
|
|
@@ -11365,7 +11455,15 @@ var defaultCallMessages = {
|
|
|
11365
11455
|
call_back_to_chat: "Back to chat",
|
|
11366
11456
|
call_summary_added: "Added to your basket: {items}",
|
|
11367
11457
|
call_summary_checkout: "Your checkout is ready.",
|
|
11368
|
-
call_on_call: "On call"
|
|
11458
|
+
call_on_call: "On call",
|
|
11459
|
+
call_say_prev: "Previous suggestions",
|
|
11460
|
+
call_say_next: "More suggestions",
|
|
11461
|
+
call_hour_one: "{n} hour",
|
|
11462
|
+
call_hour_other: "{n} hours",
|
|
11463
|
+
call_minute_one: "{n} minute",
|
|
11464
|
+
call_minute_other: "{n} minutes",
|
|
11465
|
+
call_second_one: "{n} second",
|
|
11466
|
+
call_second_other: "{n} seconds"
|
|
11369
11467
|
};
|
|
11370
11468
|
/** One message, from the host's catalogue when it has the key. */
|
|
11371
11469
|
function callText(messages, key) {
|
|
@@ -11416,6 +11514,39 @@ function formatCallTime(ms) {
|
|
|
11416
11514
|
const s = Math.max(0, Math.floor(ms / 1e3));
|
|
11417
11515
|
return `${String(Math.floor(s / 60)).padStart(2, "0")}:${String(s % 60).padStart(2, "0")}`;
|
|
11418
11516
|
}
|
|
11517
|
+
/**
|
|
11518
|
+
* A call's length three ways: `mm:ss` for the eye, an ISO 8601 duration for
|
|
11519
|
+
* `<time dateTime>`, and words for a screen reader ("1 hour 1 minute 1
|
|
11520
|
+
* second") from `Intl.NumberFormat`'s long units in `locale`, so every CLDR
|
|
11521
|
+
* plural form comes with no catalogue key; a locale it cannot parse speaks
|
|
11522
|
+
* English. A zero part is left out unless it is all there is.
|
|
11523
|
+
*/
|
|
11524
|
+
function callTime(ms, locale = "en") {
|
|
11525
|
+
const s = Math.max(0, Math.floor(ms / 1e3));
|
|
11526
|
+
const h = Math.floor(s / 3600);
|
|
11527
|
+
const m = Math.floor(s / 60) % 60;
|
|
11528
|
+
const unit = (n, u) => {
|
|
11529
|
+
const style = {
|
|
11530
|
+
style: "unit",
|
|
11531
|
+
unit: u,
|
|
11532
|
+
unitDisplay: "long"
|
|
11533
|
+
};
|
|
11534
|
+
try {
|
|
11535
|
+
return new Intl.NumberFormat(locale, style).format(n);
|
|
11536
|
+
} catch {
|
|
11537
|
+
return new Intl.NumberFormat("en", style).format(n);
|
|
11538
|
+
}
|
|
11539
|
+
};
|
|
11540
|
+
return {
|
|
11541
|
+
text: formatCallTime(ms),
|
|
11542
|
+
iso: `PT${h}H${m}M${s % 60}S`,
|
|
11543
|
+
words: [
|
|
11544
|
+
h && unit(h, "hour"),
|
|
11545
|
+
m && unit(m, "minute"),
|
|
11546
|
+
(s % 60 || s < 60) && unit(s % 60, "second")
|
|
11547
|
+
].filter(Boolean).join(" ")
|
|
11548
|
+
};
|
|
11549
|
+
}
|
|
11419
11550
|
var IDLE_CALL_RECORD = {
|
|
11420
11551
|
id: 0,
|
|
11421
11552
|
active: false,
|
|
@@ -11497,25 +11628,36 @@ function useCallMode(voice, call) {
|
|
|
11497
11628
|
const [textCall, setTextCall] = useState(0);
|
|
11498
11629
|
const [closedCall, setClosedCall] = useState(0);
|
|
11499
11630
|
const now = useNow(counting(record));
|
|
11631
|
+
const onCall = callText(call?.messages ?? defaultWidgetMessages, "call_on_call");
|
|
11632
|
+
const time = counting(record) ? callTime(now - record.startedAt, call?.locale) : void 0;
|
|
11500
11633
|
return {
|
|
11501
11634
|
shown: call !== void 0 && voice !== void 0 && textCall !== record.id && (record.active || record.endedAt !== null && closedCall !== record.id),
|
|
11502
11635
|
record,
|
|
11503
|
-
launcherLabel:
|
|
11636
|
+
launcherLabel: time && `${onCall} · ${time.text}`,
|
|
11637
|
+
launcherSpoken: time && `${onCall}, ${time.words}`,
|
|
11504
11638
|
toText: () => setTextCall(record.id),
|
|
11505
11639
|
backToCall: () => setTextCall(0),
|
|
11506
11640
|
closeSummary: () => setClosedCall(record.id)
|
|
11507
11641
|
};
|
|
11508
11642
|
}
|
|
11509
|
-
|
|
11643
|
+
/**
|
|
11644
|
+
* The call's length, live or final. A `timer` that never announces itself
|
|
11645
|
+
* (one announcement a second would drown the call), read as words on demand.
|
|
11646
|
+
*/
|
|
11647
|
+
function CallTimer({ record, locale }) {
|
|
11510
11648
|
const now = useNow(counting(record));
|
|
11511
|
-
|
|
11649
|
+
const time = callTime(record.startedAt === null ? 0 : (record.endedAt ?? now) - record.startedAt, locale);
|
|
11650
|
+
return /* @__PURE__ */ jsxs("time", {
|
|
11512
11651
|
role: "timer",
|
|
11652
|
+
"aria-live": "off",
|
|
11653
|
+
"aria-label": time.words,
|
|
11654
|
+
dateTime: time.iso,
|
|
11513
11655
|
"data-testid": "widget-call-timer",
|
|
11514
11656
|
className: "wgc-tm",
|
|
11515
11657
|
children: [counting(record) ? /* @__PURE__ */ jsx("i", {
|
|
11516
11658
|
"aria-hidden": true,
|
|
11517
11659
|
"data-testid": "widget-call-live"
|
|
11518
|
-
}) : null,
|
|
11660
|
+
}) : null, time.text]
|
|
11519
11661
|
});
|
|
11520
11662
|
}
|
|
11521
11663
|
/**
|
|
@@ -11524,7 +11666,7 @@ function CallTimer({ record }) {
|
|
|
11524
11666
|
* then the summary once it ends. Styled by `styles/call-view.css` (`.wgc`).
|
|
11525
11667
|
* See docs/CONCIERGE_GENERATIONS.md "Call mode".
|
|
11526
11668
|
*/
|
|
11527
|
-
function CallView({ state, callerSpeaking = false, turns, renderCards, suggestions, onSay, checkout = false, cart, messages, voice, name, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
|
|
11669
|
+
function CallView({ state, callerSpeaking = false, turns, renderCards, suggestions, onSay, checkout = false, cart, messages, locale, voice, name, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
|
|
11528
11670
|
const t = (key) => callText(messages, key);
|
|
11529
11671
|
const ended = !record.active;
|
|
11530
11672
|
const { word, explain } = callStatus(state, {
|
|
@@ -11545,6 +11687,7 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11545
11687
|
const interrupting = voice.agentSpeaking === true && voice.onInterrupt !== void 0;
|
|
11546
11688
|
const fixable = voice.phase === "blocked" && voice.onFixPermission !== void 0;
|
|
11547
11689
|
const lines = !ended && onSay && (state === "muted" || state === "listening" && !callerSpeaking) ? suggestions.filter((line) => !said.includes(line)) : [];
|
|
11690
|
+
const say = useScrollRow(t("call_say_prev"), t("call_say_next"), lines.length);
|
|
11548
11691
|
const added = ended ? addedDuringCall(record.cart, cart ?? []) : [];
|
|
11549
11692
|
const mark = /* @__PURE__ */ jsx(AvatarFace, {
|
|
11550
11693
|
avatar,
|
|
@@ -11585,7 +11728,10 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11585
11728
|
className: "sr-only",
|
|
11586
11729
|
children: (ended || explain && state !== "ducked") && !(explain && hint) ? t(word) : null
|
|
11587
11730
|
}),
|
|
11588
|
-
/* @__PURE__ */ jsx(CallTimer, {
|
|
11731
|
+
/* @__PURE__ */ jsx(CallTimer, {
|
|
11732
|
+
record,
|
|
11733
|
+
locale
|
|
11734
|
+
}),
|
|
11589
11735
|
actions
|
|
11590
11736
|
]
|
|
11591
11737
|
}),
|
|
@@ -11602,6 +11748,8 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11602
11748
|
/* @__PURE__ */ jsx("div", {
|
|
11603
11749
|
ref: streamRef,
|
|
11604
11750
|
role: "log",
|
|
11751
|
+
tabIndex: 0,
|
|
11752
|
+
"aria-label": messages.conversation,
|
|
11605
11753
|
className: "wgc-log no-scrollbar",
|
|
11606
11754
|
children: /* @__PURE__ */ jsx("div", {
|
|
11607
11755
|
ref: contentRef,
|
|
@@ -11617,6 +11765,7 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11617
11765
|
"data-cut": turn.cut || turn.filler ? "" : void 0,
|
|
11618
11766
|
"data-cur": i === shown.length - 1 && !ended ? "" : void 0,
|
|
11619
11767
|
"data-partial": turn.final === false ? "" : void 0,
|
|
11768
|
+
"aria-hidden": turn.final === false ? true : void 0,
|
|
11620
11769
|
className: "wgc-tx",
|
|
11621
11770
|
children: [stripBidiControls(turn.text), turn.cut ? /* @__PURE__ */ jsx("span", {
|
|
11622
11771
|
className: "wgc-cut",
|
|
@@ -11632,20 +11781,24 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11632
11781
|
}),
|
|
11633
11782
|
lines.length > 0 ? /* @__PURE__ */ jsxs("div", {
|
|
11634
11783
|
className: "wgc-say",
|
|
11635
|
-
children: [/* @__PURE__ */ jsx("p", { children: t("call_try_saying") }), /* @__PURE__ */
|
|
11636
|
-
|
|
11637
|
-
"
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11784
|
+
children: [/* @__PURE__ */ jsx("p", { children: t("call_try_saying") }), /* @__PURE__ */ jsxs("div", {
|
|
11785
|
+
className: "wsr",
|
|
11786
|
+
children: [/* @__PURE__ */ jsx("ul", {
|
|
11787
|
+
"data-testid": "widget-suggestions",
|
|
11788
|
+
"aria-label": messages.suggestions_label,
|
|
11789
|
+
...say.row,
|
|
11790
|
+
children: lines.map((line) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
11791
|
+
type: "button",
|
|
11792
|
+
"data-testid": "widget-suggestion",
|
|
11793
|
+
className: "wgc-chip",
|
|
11794
|
+
onClick: () => {
|
|
11795
|
+
Promise.resolve(onSay?.(line)).then((sent) => {
|
|
11796
|
+
if (sent !== false) setSaid((prev) => [...prev, line]);
|
|
11797
|
+
});
|
|
11798
|
+
},
|
|
11799
|
+
children: line
|
|
11800
|
+
}) }, line))
|
|
11801
|
+
}), say.arrows]
|
|
11649
11802
|
})]
|
|
11650
11803
|
}) : null,
|
|
11651
11804
|
ended ? /* @__PURE__ */ jsxs("section", {
|
|
@@ -11673,7 +11826,7 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
|
|
|
11673
11826
|
"data-testid": testIds?.endCall,
|
|
11674
11827
|
"data-end": "",
|
|
11675
11828
|
onClick: voice.onEnd,
|
|
11676
|
-
"aria-label": voice.labels.end ??
|
|
11829
|
+
"aria-label": voice.labels.end ?? defaultWidgetMessages.call_end,
|
|
11677
11830
|
children: /* @__PURE__ */ jsx(PhoneOff, {})
|
|
11678
11831
|
}) : null,
|
|
11679
11832
|
/* @__PURE__ */ jsx("button", {
|
|
@@ -11836,7 +11989,10 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11836
11989
|
...launcherInitials !== void 0 ? { initials: launcherInitials } : {},
|
|
11837
11990
|
...launcherVariant !== void 0 ? { launcher: launcherVariant } : {},
|
|
11838
11991
|
...agentName !== void 0 ? { agentName } : {},
|
|
11839
|
-
...callLabel !== void 0 ? {
|
|
11992
|
+
...callLabel !== void 0 ? {
|
|
11993
|
+
callLabel,
|
|
11994
|
+
callSrLabel: callMode.launcherSpoken
|
|
11995
|
+
} : {}
|
|
11840
11996
|
}),
|
|
11841
11997
|
/* @__PURE__ */ jsx("div", {
|
|
11842
11998
|
"aria-hidden": true,
|
|
@@ -12010,8 +12166,8 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
12010
12166
|
type: "button",
|
|
12011
12167
|
onClick: voice.onEnd,
|
|
12012
12168
|
"data-testid": testIds?.endCall,
|
|
12013
|
-
title: voice.labels.end ??
|
|
12014
|
-
"aria-label": voice.labels.end ??
|
|
12169
|
+
title: voice.labels.end ?? defaultWidgetMessages.call_end,
|
|
12170
|
+
"aria-label": voice.labels.end ?? defaultWidgetMessages.call_end,
|
|
12015
12171
|
"data-end": "",
|
|
12016
12172
|
className: "wgp-ib",
|
|
12017
12173
|
children: /* @__PURE__ */ jsx(PhoneOff, {})
|
|
@@ -12381,7 +12537,7 @@ function positionFor(dock) {
|
|
|
12381
12537
|
const align = dock?.layout?.desktopAlign;
|
|
12382
12538
|
return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
|
|
12383
12539
|
}
|
|
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 }) {
|
|
12540
|
+
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, replyStreaming, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, renderCards, suggestions, call: callHooks, cart, dock, locale }) {
|
|
12385
12541
|
const [restored] = useState(readOpen);
|
|
12386
12542
|
const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
|
|
12387
12543
|
const onShown = dock?.onShown;
|
|
@@ -12497,7 +12653,8 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
12497
12653
|
const handoffAt = turns.findLastIndex((t) => t.event === "handoff");
|
|
12498
12654
|
const promiseKept = view.status?.kind === "message" && view.status.key === "escalated_banner" && turns.slice(handoffAt + 1).some((t) => t.speaker === "agent" && t.text.trim() !== "");
|
|
12499
12655
|
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
|
|
12656
|
+
const restatesCaption = view.status?.kind === "text" && view.status.text === dock?.partialTranscript;
|
|
12657
|
+
const statusText = view.status === null || promiseKept || restatesPill || restatesCaption ? void 0 : view.status.kind === "text" ? view.status.text : messages[view.status.key] ?? void 0;
|
|
12501
12658
|
const voice = showMic ? {
|
|
12502
12659
|
phase: callPhase,
|
|
12503
12660
|
onStart: onToggleMic,
|
|
@@ -12591,7 +12748,8 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
12591
12748
|
...callHooks?.sendText !== void 0 ? { onSay: callHooks.sendText } : {},
|
|
12592
12749
|
...checkout !== void 0 ? { checkout } : {},
|
|
12593
12750
|
...cart !== void 0 ? { cart: cart.lines } : {},
|
|
12594
|
-
messages
|
|
12751
|
+
messages,
|
|
12752
|
+
locale
|
|
12595
12753
|
} } : {},
|
|
12596
12754
|
composerLeading,
|
|
12597
12755
|
badge: statusText === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
@@ -12742,7 +12900,7 @@ var INLINE_CARD_LIMIT = 4;
|
|
|
12742
12900
|
* branches, each still driving image sizing/shape and the wrapper's flex
|
|
12743
12901
|
* direction together — extended, not duplicated into a second component.
|
|
12744
12902
|
*/
|
|
12745
|
-
function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect }) {
|
|
12903
|
+
function CardBody({ item, titleId, href, roomy, locale, navigate, showPrice, imageAspect }) {
|
|
12746
12904
|
const imageBox = {
|
|
12747
12905
|
"data-testid": "widget-card-image",
|
|
12748
12906
|
"data-aspect": imageAspect,
|
|
@@ -12750,7 +12908,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12750
12908
|
};
|
|
12751
12909
|
const inner = /* @__PURE__ */ jsxs(Fragment, { children: [item.imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
12752
12910
|
src: item.imageUrl,
|
|
12753
|
-
alt:
|
|
12911
|
+
alt: "",
|
|
12754
12912
|
loading: "lazy",
|
|
12755
12913
|
decoding: "async",
|
|
12756
12914
|
className: roomy ? "h-[4.5rem] w-auto shrink-0 rounded-lg object-cover" : "h-auto w-full rounded-lg object-cover",
|
|
@@ -12763,6 +12921,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12763
12921
|
className: "w-full min-w-0 flex-1",
|
|
12764
12922
|
children: [
|
|
12765
12923
|
/* @__PURE__ */ jsx("p", {
|
|
12924
|
+
id: titleId,
|
|
12766
12925
|
className: "truncate text-sm font-medium text-[var(--widget-foreground)]",
|
|
12767
12926
|
children: item.title
|
|
12768
12927
|
}),
|
|
@@ -12810,7 +12969,7 @@ function CardBody({ item, href, roomy, locale, navigate, showPrice, imageAspect
|
|
|
12810
12969
|
* Changing quantity is the cart drawer's job, which is a surface that can show
|
|
12811
12970
|
* the quantity it is changing.
|
|
12812
12971
|
*/
|
|
12813
|
-
function AddToCartButton({ item, onAddToCart, messages, fullWidth = false }) {
|
|
12972
|
+
function AddToCartButton({ item, describedBy, onAddToCart, messages, fullWidth = false }) {
|
|
12814
12973
|
const [phase, setPhase] = useState("idle");
|
|
12815
12974
|
const mounted = useRef(true);
|
|
12816
12975
|
useEffect(() => {
|
|
@@ -12835,6 +12994,7 @@ function AddToCartButton({ item, onAddToCart, messages, fullWidth = false }) {
|
|
|
12835
12994
|
type: "button",
|
|
12836
12995
|
"data-testid": "widget-card-add-to-cart",
|
|
12837
12996
|
"data-phase": "unavailable",
|
|
12997
|
+
"aria-describedby": describedBy,
|
|
12838
12998
|
disabled: true,
|
|
12839
12999
|
className: `cursor-default rounded-full bg-black/5 px-3 py-1.5 text-xs font-medium text-[var(--widget-foreground-muted)] ${fullWidth ? "w-full text-center" : "shrink-0"}`,
|
|
12840
13000
|
children: messages.unavailable
|
|
@@ -12843,6 +13003,7 @@ function AddToCartButton({ item, onAddToCart, messages, fullWidth = false }) {
|
|
|
12843
13003
|
type: "button",
|
|
12844
13004
|
"data-testid": "widget-card-add-to-cart",
|
|
12845
13005
|
"data-phase": phase,
|
|
13006
|
+
"aria-describedby": describedBy,
|
|
12846
13007
|
disabled,
|
|
12847
13008
|
"aria-live": "polite",
|
|
12848
13009
|
onClick: () => void onClick(),
|
|
@@ -12935,42 +13096,63 @@ function ChooseOptionsButton({ item, onChooseOptions, messages, fullWidth = fals
|
|
|
12935
13096
|
* bigger canvas of its own page rather than an unbounded scroll.
|
|
12936
13097
|
*/
|
|
12937
13098
|
function WidgetCardList({ cards, onAddToCart, onChooseOptions, chooseOptionsBusy = false, curationHref, productHref, navigate, locale = "en", messages = defaultWidgetMessages, roomy = false, showPrice = true, imageAspect = DEFAULT_CARD_ASPECT }) {
|
|
12938
|
-
|
|
13099
|
+
const text = (key) => messages[key] ?? defaultWidgetMessages[key];
|
|
13100
|
+
const id = useId();
|
|
12939
13101
|
const visibleItems = cards.items.slice(0, INLINE_CARD_LIMIT);
|
|
13102
|
+
const { row, arrows } = useScrollRow(text("cards_prev"), text("cards_next"), visibleItems.length);
|
|
13103
|
+
if (cards.items.length === 0) return null;
|
|
12940
13104
|
const seeAllHref = cards.items.length - visibleItems.length > 0 && cards.curationId && curationHref ? curationHref(cards.curationId) : void 0;
|
|
12941
13105
|
return /* @__PURE__ */ jsxs("div", {
|
|
12942
13106
|
className: "mt-2 flex flex-col gap-2",
|
|
12943
|
-
children: [/* @__PURE__ */
|
|
12944
|
-
|
|
12945
|
-
|
|
12946
|
-
|
|
12947
|
-
|
|
12948
|
-
|
|
12949
|
-
|
|
12950
|
-
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12954
|
-
|
|
12955
|
-
|
|
12956
|
-
|
|
12957
|
-
|
|
12958
|
-
|
|
12959
|
-
|
|
12960
|
-
|
|
12961
|
-
|
|
12962
|
-
|
|
12963
|
-
|
|
12964
|
-
|
|
12965
|
-
|
|
12966
|
-
|
|
12967
|
-
|
|
12968
|
-
|
|
12969
|
-
|
|
12970
|
-
|
|
12971
|
-
|
|
12972
|
-
|
|
12973
|
-
|
|
13107
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
13108
|
+
className: "wsr",
|
|
13109
|
+
...roomy ? {} : {
|
|
13110
|
+
role: "group",
|
|
13111
|
+
"aria-roledescription": text("cards_carousel"),
|
|
13112
|
+
"aria-label": text("cards_label")
|
|
13113
|
+
},
|
|
13114
|
+
children: [/* @__PURE__ */ jsx("ul", {
|
|
13115
|
+
"data-testid": "widget-card-list",
|
|
13116
|
+
"data-layout": roomy ? "grid" : "carousel",
|
|
13117
|
+
...roomy ? {} : row,
|
|
13118
|
+
className: roomy ? "grid grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-2" : "card-carousel flex snap-x snap-mandatory gap-2 overflow-x-auto overscroll-x-contain",
|
|
13119
|
+
children: visibleItems.map((item, i) => {
|
|
13120
|
+
const href = item.handle && productHref ? productHref(item.handle) : void 0;
|
|
13121
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
13122
|
+
"data-testid": "widget-card",
|
|
13123
|
+
...roomy ? {} : {
|
|
13124
|
+
"aria-roledescription": text("cards_slide_role"),
|
|
13125
|
+
"aria-label": formatMessage(text("cards_slide"), {
|
|
13126
|
+
n: i + 1,
|
|
13127
|
+
total: visibleItems.length
|
|
13128
|
+
})
|
|
13129
|
+
},
|
|
13130
|
+
className: `flex flex-col items-start gap-3 rounded-xl border border-black/10 bg-[var(--widget-card)] p-2 ${roomy ? "" : "min-w-0 shrink-0 basis-[calc(100%/1.25)] max-w-[180px] snap-start"}`,
|
|
13131
|
+
children: [/* @__PURE__ */ jsx(CardBody, {
|
|
13132
|
+
item,
|
|
13133
|
+
titleId: `${id}-t${i}`,
|
|
13134
|
+
href,
|
|
13135
|
+
roomy,
|
|
13136
|
+
locale,
|
|
13137
|
+
navigate,
|
|
13138
|
+
showPrice,
|
|
13139
|
+
imageAspect
|
|
13140
|
+
}), item.variantChoiceRequired === true && item.available ? /* @__PURE__ */ jsx(ChooseOptionsButton, {
|
|
13141
|
+
item,
|
|
13142
|
+
onChooseOptions,
|
|
13143
|
+
messages,
|
|
13144
|
+
fullWidth: !roomy,
|
|
13145
|
+
busy: chooseOptionsBusy
|
|
13146
|
+
}) : /* @__PURE__ */ jsx(AddToCartButton, {
|
|
13147
|
+
item,
|
|
13148
|
+
describedBy: `${id}-t${i}`,
|
|
13149
|
+
onAddToCart,
|
|
13150
|
+
messages,
|
|
13151
|
+
fullWidth: !roomy
|
|
13152
|
+
})]
|
|
13153
|
+
}, `${item.productId}-${item.variantId ?? ""}`);
|
|
13154
|
+
})
|
|
13155
|
+
}), roomy ? null : arrows]
|
|
12974
13156
|
}), seeAllHref ? /* @__PURE__ */ jsx("a", {
|
|
12975
13157
|
href: seeAllHref,
|
|
12976
13158
|
"data-testid": "widget-card-see-all",
|
|
@@ -13035,7 +13217,7 @@ function WidgetCartSummary({ lines, subtotalMinor, currency, discountMinor, onCh
|
|
|
13035
13217
|
children: [
|
|
13036
13218
|
line.imageUrl ? /* @__PURE__ */ jsx("img", {
|
|
13037
13219
|
src: line.imageUrl,
|
|
13038
|
-
alt:
|
|
13220
|
+
alt: "",
|
|
13039
13221
|
className: "h-9 w-9 shrink-0 rounded-lg object-cover"
|
|
13040
13222
|
}) : /* @__PURE__ */ jsx("span", {
|
|
13041
13223
|
"aria-hidden": "true",
|
|
@@ -16651,6 +16833,11 @@ async function streamReply(args) {
|
|
|
16651
16833
|
}
|
|
16652
16834
|
//#endregion
|
|
16653
16835
|
//#region src/spoken-transcript.ts
|
|
16836
|
+
/** The caller's words while they are still speaking, if the newest caller line is provisional. */
|
|
16837
|
+
function liveCallerCaption(lines) {
|
|
16838
|
+
const line = lines.findLast((l) => l.speaker === "caller");
|
|
16839
|
+
return line?.final === false && line.text || void 0;
|
|
16840
|
+
}
|
|
16654
16841
|
/** The words of `provisional` after the `settled` prefix the caller heard. */
|
|
16655
16842
|
function droppedWords(settled, provisional) {
|
|
16656
16843
|
return provisional.trim().slice(settled.trim().length).split(/\s+/u).filter(Boolean).length;
|
|
@@ -16764,7 +16951,7 @@ function callStartStamp(spoken, others) {
|
|
|
16764
16951
|
* cache makes a second `start()` after `stop()` free).
|
|
16765
16952
|
*/
|
|
16766
16953
|
async function loadVoiceProtocol() {
|
|
16767
|
-
const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-
|
|
16954
|
+
const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-Bm4MPdY9.js")]);
|
|
16768
16955
|
return {
|
|
16769
16956
|
decodeTelemetry: telemetry.decodeTelemetry,
|
|
16770
16957
|
encodeCallerText: telemetry.encodeCallerText,
|
|
@@ -16909,6 +17096,7 @@ function isCutShort(settled, provisional) {
|
|
|
16909
17096
|
function coalesceTranscript(lines, line) {
|
|
16910
17097
|
const at = lines.findLastIndex((existing) => existing.speaker === line.speaker);
|
|
16911
17098
|
const open = at >= 0 ? lines[at] : void 0;
|
|
17099
|
+
if (line.speaker === "caller" && !line.final && line.text === "") return open?.final === false ? lines.filter((l) => l !== open) : lines;
|
|
16912
17100
|
if (open === void 0 || open.final) return [...lines, line].slice(-50);
|
|
16913
17101
|
const revised = line.speaker === "agent" && !line.final && line.cumulative !== true ? {
|
|
16914
17102
|
...line,
|
|
@@ -18331,7 +18519,8 @@ var TurnOrderClock = class {
|
|
|
18331
18519
|
* Inheritance is disabled outright on a render where the list SHRANK:
|
|
18332
18520
|
* appends and revisions never shrink it and the cap trim keeps the length
|
|
18333
18521
|
* constant, so a shorter list means rows were dropped (`start()`'s reset to
|
|
18334
|
-
* `[]` for a new call,
|
|
18522
|
+
* `[]` for a new call, a retracted live caller caption, or any future
|
|
18523
|
+
* producer change) — and a dropped
|
|
18335
18524
|
* line's stamp must never be donated to a newcomer that merely stands where
|
|
18336
18525
|
* it stood. Surviving identical rows still keep their stamps; everything
|
|
18337
18526
|
* else restamps fresh, i.e. the new call's lines sort after everything
|
|
@@ -19518,8 +19707,10 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19518
19707
|
if (!inCallRef.current) await waitForTypedTurnToLand();
|
|
19519
19708
|
if (!actLiveRef.current || typeof window === "undefined") return;
|
|
19520
19709
|
try {
|
|
19521
|
-
const { fillHostForm } = await import("./form-fill-dom-
|
|
19522
|
-
if (actLiveRef.current)
|
|
19710
|
+
const { fillHostForm } = await import("./form-fill-dom-Dxt-z0H0.js");
|
|
19711
|
+
if (!actLiveRef.current) return;
|
|
19712
|
+
const report = fillHostForm(window.document, event);
|
|
19713
|
+
if (!inCallRef.current) session.sendReport(report, { quietOnHttpError: true }).catch(() => void 0);
|
|
19523
19714
|
} catch {}
|
|
19524
19715
|
return;
|
|
19525
19716
|
}
|
|
@@ -20589,6 +20780,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20589
20780
|
* and §4.2's handover payload, both of which this component only forwards.
|
|
20590
20781
|
* See `VoiceWidgetProps.dock` for why the split runs here.
|
|
20591
20782
|
*/
|
|
20783
|
+
const partialTranscript = inCall ? liveCallerCaption(voice.transcript) : void 0;
|
|
20592
20784
|
const dockProps = {
|
|
20593
20785
|
identity: {
|
|
20594
20786
|
name: identity?.name ?? "",
|
|
@@ -20606,6 +20798,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
20606
20798
|
...direction !== void 0 ? { direction } : {},
|
|
20607
20799
|
...proactive !== void 0 ? { proactive } : {},
|
|
20608
20800
|
channel: inCall ? "voice" : "text",
|
|
20801
|
+
...partialTranscript !== void 0 ? { partialTranscript } : {},
|
|
20609
20802
|
reconnecting: session.resuming || voiceEnabled && voice.phase === "disconnected",
|
|
20610
20803
|
roomDropped: voiceEnabled && voice.phase === "disconnected",
|
|
20611
20804
|
...latestCuration ? { shelf: latestCuration } : {},
|