@saar-ai/web-widget 0.22.0 → 0.24.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.
Files changed (36) hide show
  1. package/dist/capture-card/capture-card-dom.d.ts +2 -0
  2. package/dist/capture-card/capture-card-dom.d.ts.map +1 -1
  3. package/dist/chunks/{capture-card-dom-_bYXscCg.js → capture-card-dom-C0IKjuBA.js} +138 -99
  4. package/dist/chunks/{chat-DrpWeT5w.js → chat-Bvu3c3dk.js} +80 -6
  5. package/dist/chunks/{host-widget-ETlw6B5z.js → host-widget-FCxPyMok.js} +260 -16
  6. package/dist/concierge-shell.css +1 -1
  7. package/dist/dock/dock-renderer.d.ts +1 -1
  8. package/dist/dock/dock-renderer.d.ts.map +1 -1
  9. package/dist/dock/dock.d.ts +5 -0
  10. package/dist/dock/dock.d.ts.map +1 -1
  11. package/dist/generated/concierge-shell-css.d.ts.map +1 -1
  12. package/dist/generated/widget-css.d.ts.map +1 -1
  13. package/dist/host-widget.d.ts.map +1 -1
  14. package/dist/index.d.ts +1 -0
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +4 -4
  17. package/dist/messages.d.ts +15 -0
  18. package/dist/messages.d.ts.map +1 -1
  19. package/dist/next/index.js +1 -1
  20. package/dist/use-chat-session.d.ts +9 -1
  21. package/dist/use-chat-session.d.ts.map +1 -1
  22. package/dist/use-voice-session.d.ts +38 -1
  23. package/dist/use-voice-session.d.ts.map +1 -1
  24. package/dist/variant-option-groups.d.ts +44 -0
  25. package/dist/variant-option-groups.d.ts.map +1 -0
  26. package/dist/variant-options.d.ts +34 -0
  27. package/dist/variant-options.d.ts.map +1 -0
  28. package/dist/voice-widget.d.ts +9 -1
  29. package/dist/voice-widget.d.ts.map +1 -1
  30. package/dist/widget/call-view.d.ts +4 -2
  31. package/dist/widget/call-view.d.ts.map +1 -1
  32. package/dist/widget/shell-renderer.d.ts +1 -1
  33. package/dist/widget/shell-renderer.d.ts.map +1 -1
  34. package/dist/widget.css +1 -1
  35. package/package.json +1 -1
  36. package/src/styles/concierge-shell-entry.css +1 -0
@@ -4681,6 +4681,9 @@ var defaultWidgetMessages = {
4681
4681
  choose_options: "Choose options",
4682
4682
  choose_options_label: "Choose options for {title}",
4683
4683
  choose_options_after_call: "I’ll ask about options after the call",
4684
+ options_label: "Choose {option} for {title}",
4685
+ options_price_from: "from {price}",
4686
+ options_added: "Added to cart",
4684
4687
  cards_label: "Recommended products",
4685
4688
  cards_slide: "{n} of {total}",
4686
4689
  cards_prev: "Previous products",
@@ -8451,7 +8454,7 @@ var DEFAULT_LAYOUT = {
8451
8454
  };
8452
8455
  var INTERRUPT_SEEN_STORAGE_KEY = "wgt_dock_interrupt_seen";
8453
8456
  function Dock(props) {
8454
- const { identity, color = DEFAULT_COLOR$1, type = DEFAULT_TYPE$1, layout = DEFAULT_LAYOUT, copy = {}, direction = "ltr", locale = "en", messages = defaultWidgetMessages, voice, escalated = false, offline = false, status, notice, statusKind, operatorLine, operatorName, reconnecting = false, roomDropped = false, partialTranscript, preamble, clause, channel = "text", shelf, transcript, transcriptCount, lastTurn, composing = false, unread = false, sheetExtra, followKey, revealSheet = false, showPrice = true, cardImageAspect = DEFAULT_CARD_ASPECT, bottomOffset = "auto", curationHref, productHref, navigate, draft, onDraftChange, onSubmit, composerDisabled = false, onAttach, attachSlot, attachBusy, proactive, pageKey, conciergeScrollRef, onEndCall, skinStyle, skin, preview = false, announcement, attribution, privacyChoices, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, onShown } = props;
8457
+ 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, voiceShelfExtra, 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;
8455
8458
  const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
8456
8459
  const rootRef = useRef(null);
8457
8460
  const rowRef = useRef(null);
@@ -9467,6 +9470,7 @@ function Dock(props) {
9467
9470
  ...productHref ? { productHref } : {},
9468
9471
  ...navigate ? { navigate } : {}
9469
9472
  }) : null,
9473
+ channel === "voice" && !showTranscript ? voiceShelfExtra : null,
9470
9474
  channel === "text" || showTranscript ? transcript : null,
9471
9475
  sheetExtra,
9472
9476
  attribution !== void 0 ? /* @__PURE__ */ jsx("a", {
@@ -11739,7 +11743,7 @@ function callMarkState(state, bot, ended, muted) {
11739
11743
  * labelled controls; then the summary once it ends. Styled by
11740
11744
  * `styles/call-view.css` (`.wgc`). See docs/CONCIERGE_GENERATIONS.md "Call mode".
11741
11745
  */
11742
- function CallView({ state, callerSpeaking = false, turns, renderCards, suggestions, choices, extras, onSay, checkout = false, cart, messages, locale, voice, name, title, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
11746
+ function CallView({ state, callerSpeaking = false, turns, renderCards, renderOptions, suggestions, choices, extras, onSay, checkout = false, cart, messages, locale, voice, name, title, actions, record, bot, avatar, hint, onText, onBackToChat, testIds }) {
11743
11747
  const t = (key) => callText(messages, key);
11744
11748
  const ended = !record.active;
11745
11749
  const { word, explain } = callStatus(state, {
@@ -11747,7 +11751,7 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
11747
11751
  callerSpeaking
11748
11752
  });
11749
11753
  const [said, setSaid] = useState([]);
11750
- 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);
11754
+ 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 || turn.options !== void 0);
11751
11755
  const last = shown[shown.length - 1];
11752
11756
  const pending = ended ? null : state === "thinking" && !(last?.speaker === "agent" && last.final === false) ? "agent" : callerSpeaking && !(last?.speaker === "caller" && last.final === false) ? "caller" : null;
11753
11757
  const streamRef = useRef(null);
@@ -11878,6 +11882,10 @@ function CallView({ state, callerSpeaking = false, turns, renderCards, suggestio
11878
11882
  !you && turn.cards && turn.cards.items.length > 0 ? /* @__PURE__ */ jsx("div", {
11879
11883
  className: "wgc-cards",
11880
11884
  children: renderCards(turn.cards)
11885
+ }) : null,
11886
+ !you && turn.options && renderOptions ? /* @__PURE__ */ jsx("div", {
11887
+ className: "wgc-cards",
11888
+ children: renderOptions(turn.options)
11881
11889
  }) : null
11882
11890
  ]
11883
11891
  }, i);
@@ -12633,7 +12641,7 @@ function positionFor(dock) {
12633
12641
  const align = dock?.layout?.desktopAlign;
12634
12642
  return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
12635
12643
  }
12636
- 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, capturing, showBasket, captureChoices, dock, locale }) {
12644
+ 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, renderOptions, suggestions, call: callHooks, cart, capturing, showBasket, captureChoices, dock, locale }) {
12637
12645
  const [restored] = useState(readOpen);
12638
12646
  const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
12639
12647
  const onShown = dock?.onShown;
@@ -12841,6 +12849,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
12841
12849
  callerSpeaking: voiceInput.callerSpeaking === true,
12842
12850
  turns,
12843
12851
  renderCards,
12852
+ renderOptions,
12844
12853
  suggestions,
12845
12854
  choices: captureChoices,
12846
12855
  ...capturing || attaching !== null || showBasket && (cart?.lines.length ?? 0) > 0 ? { extras } : {},
@@ -12884,7 +12893,9 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
12884
12893
  * Imported by `cdn/ui.ts` and by `rendererFor`; never by `voice-widget.tsx`,
12885
12894
  * so a bundle built around the OTHER renderer does not carry this one.
12886
12895
  */
12887
- function DockRenderer({ turns, lastTurn, operatorName, composing, onEndCall, voice, statusLine, statusKind, notice, escalated, humanTyping, draft, onDraftChange, submit, showBasket, cart, attaching, capturing, onAttach, attachInput, transcript, extras, messages, locale, navigate, curationHref, productHref, skinStyle, avatar, attribution, privacyChoices, dock }) {
12896
+ function DockRenderer({ turns, lastTurn, operatorName, composing, onEndCall, voice, statusLine, statusKind, notice, escalated, humanTyping, draft, onDraftChange, submit, showBasket, cart, attaching, capturing, onAttach, attachInput, transcript, renderOptions, extras, messages, locale, navigate, curationHref, productHref, skinStyle, avatar, attribution, privacyChoices, dock }) {
12897
+ const asked = turns.findLastIndex((turn) => turn.options !== void 0);
12898
+ const openOptions = asked >= 0 && !turns.slice(asked + 1).some((turn) => turn.speaker === "caller") ? turns[asked]?.options : void 0;
12888
12899
  return /* @__PURE__ */ jsx(Dock, {
12889
12900
  identity: {
12890
12901
  name: "",
@@ -12912,12 +12923,13 @@ function DockRenderer({ turns, lastTurn, operatorName, composing, onEndCall, voi
12912
12923
  draft,
12913
12924
  onDraftChange,
12914
12925
  onSubmit: submit,
12915
- revealSheet: showBasket && cart !== void 0 && cart.lines.length > 0 || attaching !== null || capturing,
12916
- followKey: turns.reduce((n, turn) => n + 1 + turn.text.length + (turn.cards?.items.length ?? 0), 0) + (humanTyping ? 1 : 0),
12926
+ revealSheet: showBasket && cart !== void 0 && cart.lines.length > 0 || attaching !== null || capturing || openOptions !== void 0,
12927
+ followKey: turns.reduce((n, turn) => n + 1 + turn.text.length + (turn.cards?.items.length ?? 0) + (turn.options ? 1 : 0), 0) + (humanTyping ? 1 : 0),
12917
12928
  ...onAttach ? { onAttach } : {},
12918
12929
  attachBusy: attaching !== null && !attaching.failed,
12919
12930
  ...attachInput !== null ? { attachSlot: attachInput } : {},
12920
12931
  sheetExtra: extras,
12932
+ ...openOptions ? { voiceShelfExtra: renderOptions(openOptions) } : {},
12921
12933
  transcript,
12922
12934
  transcriptCount: turns.length,
12923
12935
  ...lastTurn !== void 0 ? { lastTurn } : {},
@@ -13266,6 +13278,170 @@ function WidgetCardList({ cards, onAddToCart, onChooseOptions, chooseOptionsBusy
13266
13278
  });
13267
13279
  }
13268
13280
  //#endregion
13281
+ //#region src/variant-option-groups.ts
13282
+ var valueOf = (variant, name) => name === "" ? variant.title : variant.options.find((o) => o.name === name)?.value;
13283
+ var fits = (variant, selected, skip) => Object.keys(selected).every((n) => n === skip || valueOf(variant, n) === selected[n]);
13284
+ /**
13285
+ * The option names the chips are grouped by, in the first variant's order:
13286
+ * only names every variant carries and whose value varies. Variants that do
13287
+ * not share one set of names (or have none) are one group of titles, so every
13288
+ * variant is still a chip.
13289
+ */
13290
+ function optionNames(variants) {
13291
+ const names = [...new Set(variants[0]?.options.map((o) => o.name))].filter((n) => variants.every((v) => v.options.length === variants[0]?.options.length && valueOf(v, n)) && new Set(variants.map((v) => valueOf(v, n))).size > 1);
13292
+ return names.length > 0 ? names : [""];
13293
+ }
13294
+ /**
13295
+ * The chips for the current selection. Each group offers the values still
13296
+ * reachable from the choices made in the groups BEFORE it, so a later group
13297
+ * never offers a combination that does not exist; each chip is priced against
13298
+ * every other choice that still fits it.
13299
+ */
13300
+ function optionGroups(variants, selected) {
13301
+ const names = optionNames(variants);
13302
+ return names.map((name, g) => {
13303
+ const earlier = Object.fromEntries(names.slice(0, g).flatMap((n) => selected[n] === void 0 ? [] : [[n, selected[n]]]));
13304
+ const reachable = variants.filter((v) => fits(v, earlier));
13305
+ return {
13306
+ name,
13307
+ chips: [...new Set(reachable.map((v) => valueOf(v, name)))].map((value) => {
13308
+ const withValue = reachable.filter((v) => valueOf(v, name) === value);
13309
+ const fitting = withValue.filter((v) => fits(v, selected, name));
13310
+ const prices = (fitting.length > 0 ? fitting : withValue).map((v) => v.priceMinor);
13311
+ const priceMinor = Math.min(...prices);
13312
+ return {
13313
+ value,
13314
+ priceMinor,
13315
+ from: prices.some((p) => p !== priceMinor)
13316
+ };
13317
+ })
13318
+ };
13319
+ });
13320
+ }
13321
+ /**
13322
+ * The selection after a tap: that value in that group, every other choice
13323
+ * kept only while some variant still has all of them.
13324
+ */
13325
+ function selectOption(variants, selected, name, value) {
13326
+ const next = { [name]: value };
13327
+ for (const n of optionNames(variants)) {
13328
+ const kept = selected[n];
13329
+ if (n === name || kept === void 0) continue;
13330
+ if (variants.some((v) => fits(v, {
13331
+ ...next,
13332
+ [n]: kept
13333
+ }))) next[n] = kept;
13334
+ }
13335
+ return next;
13336
+ }
13337
+ /** The one variant a complete selection names, or `undefined` while any group is unchosen. */
13338
+ function resolvedVariant(variants, selected) {
13339
+ return optionNames(variants).every((n) => selected[n] !== void 0) ? variants.find((v) => fits(v, selected)) : void 0;
13340
+ }
13341
+ /**
13342
+ * The cart item a chosen variant adds: the product's display fields plus THIS
13343
+ * variant's ids and price. The same shape a card's Add button hands
13344
+ * `resolveAddToCartHandler`, so a chip adds through the one add path.
13345
+ */
13346
+ function cartItemFor({ product }, { variantId, platformVariantId, priceMinor }) {
13347
+ return {
13348
+ ...product,
13349
+ variantId,
13350
+ ...platformVariantId !== void 0 ? { platformVariantId } : {},
13351
+ priceMinor,
13352
+ available: true
13353
+ };
13354
+ }
13355
+ //#endregion
13356
+ //#region src/variant-options.tsx
13357
+ /**
13358
+ * SAA-509 — the variant choice as tappable chips under the line that asks
13359
+ * for it ("Which size?"): one row per option (Size, Colour…), each chip a
13360
+ * value and its price. Only in-stock variants reach it, so there is no
13361
+ * sold-out state to draw.
13362
+ *
13363
+ * A tap that completes the choice adds that variant through `onAddToCart`,
13364
+ * the one path every add takes, and the concierge hears of it through the
13365
+ * `cart_add` report that path sends; on a call it is said instead (`onSay`).
13366
+ * A tap that leaves an option unchosen narrows the next row; after an add the
13367
+ * next tap starts a fresh choice, and a tap on the added chip does nothing.
13368
+ * Chips are `aria-pressed` toggles in labelled groups, and stay focusable
13369
+ * while inert (`aria-disabled`, as card buttons do).
13370
+ */
13371
+ function VariantOptionChips({ options, onAddToCart, messages, locale, showPrice = true, onSay, busy = false }) {
13372
+ const [selected, setSelected] = useState({});
13373
+ const [adding, setAdding] = useState(false);
13374
+ const [added, setAdded] = useState([]);
13375
+ const addingRef = useRef(false);
13376
+ const { variants, product } = options;
13377
+ const chosen = resolvedVariant(variants, selected);
13378
+ const text = (key) => messages[key] ?? defaultWidgetMessages[key];
13379
+ const inert = !onAddToCart && !onSay || adding || busy;
13380
+ const pick = async (name, value) => {
13381
+ if (inert || addingRef.current) return;
13382
+ const done = chosen !== void 0 && added.includes(chosen.variantId);
13383
+ if (done && selected[name] === value) return;
13384
+ const next = selectOption(variants, done ? {} : selected, name, value);
13385
+ setSelected(next);
13386
+ const variant = resolvedVariant(variants, next);
13387
+ if (!variant) return;
13388
+ addingRef.current = true;
13389
+ setAdding(true);
13390
+ try {
13391
+ if (onSay) await onSay([product.title, ...Object.values(next)].join(", "));
13392
+ else {
13393
+ await onAddToCart?.(cartItemFor(options, variant));
13394
+ setAdded((prev) => [...prev, variant.variantId]);
13395
+ }
13396
+ } catch {} finally {
13397
+ addingRef.current = false;
13398
+ setAdding(false);
13399
+ }
13400
+ };
13401
+ const groups = optionGroups(variants, selected);
13402
+ return /* @__PURE__ */ jsx("div", {
13403
+ "data-testid": "widget-variant-options",
13404
+ className: "flex w-full flex-col gap-2 pt-1",
13405
+ children: groups.map((group) => /* @__PURE__ */ jsxs("div", {
13406
+ role: "group",
13407
+ "aria-label": formatMessage(text("options_label"), {
13408
+ option: group.name || product.title,
13409
+ title: product.title
13410
+ }),
13411
+ children: [groups.length > 1 ? /* @__PURE__ */ jsx("p", {
13412
+ "aria-hidden": "true",
13413
+ className: "px-1 pb-1 text-[11px] font-medium text-[var(--widget-foreground-muted)]",
13414
+ children: group.name
13415
+ }) : null, /* @__PURE__ */ jsx("ul", {
13416
+ className: "flex flex-wrap gap-1.5",
13417
+ children: group.chips.map((chip) => {
13418
+ const pressed = selected[group.name] === chip.value;
13419
+ const done = pressed && chosen !== void 0 && added.includes(chosen.variantId);
13420
+ const price = formatMoney(chip.priceMinor, product.currency, locale);
13421
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("button", {
13422
+ type: "button",
13423
+ "data-testid": "widget-variant-option",
13424
+ "data-phase": pressed && adding ? "adding" : done ? "added" : "idle",
13425
+ "aria-pressed": pressed,
13426
+ "aria-disabled": inert,
13427
+ onClick: () => void pick(group.name, chip.value),
13428
+ className: "cursor-pointer rounded-full bg-[var(--widget-chip)] px-3 py-1.5 text-xs font-medium text-[var(--widget-foreground)] ring-1 ring-black/10 transition-colors hover:bg-[var(--widget-accent)] hover:text-[var(--widget-accent-foreground)] focus-visible:ring-2 focus-visible:ring-[var(--widget-accent-ring)] focus-visible:outline-none aria-disabled:cursor-default aria-pressed:bg-[var(--widget-accent)] aria-pressed:text-[var(--widget-accent-foreground)]",
13429
+ children: [
13430
+ done ? "✓ " : "",
13431
+ /* @__PURE__ */ jsx("bdi", { children: chip.value }),
13432
+ showPrice ? ` · ${chip.from ? formatMessage(text("options_price_from"), { price }) : price}` : "",
13433
+ done ? /* @__PURE__ */ jsxs("span", {
13434
+ className: "sr-only",
13435
+ children: [" ", text("options_added")]
13436
+ }) : null
13437
+ ]
13438
+ }) }, chip.value);
13439
+ })
13440
+ })]
13441
+ }, group.name))
13442
+ });
13443
+ }
13444
+ //#endregion
13269
13445
  //#region src/widget-cart-summary.tsx
13270
13446
  /**
13271
13447
  * The basket, inside the conversation.
@@ -13826,6 +14002,16 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
13826
14002
  ...dock?.showPrice !== void 0 ? { showPrice: dock.showPrice } : {},
13827
14003
  ...dock?.cardImageAspect !== void 0 ? { imageAspect: dock.cardImageAspect } : {}
13828
14004
  });
14005
+ const sayOnCall = (callPhase === "live" || callPhase === "waiting") && call?.sendText ? call.sendText : void 0;
14006
+ const renderOptions = (options) => /* @__PURE__ */ jsx(VariantOptionChips, {
14007
+ options,
14008
+ ...onAddToCart ? { onAddToCart } : {},
14009
+ ...sayOnCall ? { onSay: sayOnCall } : {},
14010
+ busy: chooseOptionsBusy,
14011
+ messages,
14012
+ locale,
14013
+ ...dock?.showPrice !== void 0 ? { showPrice: dock.showPrice } : {}
14014
+ }, `${options.product.productId}:${options.variants.map((v) => v.variantId).join()}`);
13829
14015
  const openers = suggestions ?? SUGGESTION_KEYS.map((key) => messages[key]);
13830
14016
  const renderLog = (shown) => /* @__PURE__ */ jsxs("div", {
13831
14017
  role: "log",
@@ -13874,6 +14060,10 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
13874
14060
  className: "w-full",
13875
14061
  children: renderCards(turn.cards)
13876
14062
  }) : null,
14063
+ turn.options ? /* @__PURE__ */ jsx("div", {
14064
+ className: "w-full",
14065
+ children: renderOptions(turn.options)
14066
+ }) : null,
13877
14067
  turn.delivery !== void 0 ? /* @__PURE__ */ jsx(TurnDeliveryStatus, {
13878
14068
  delivery: turn.delivery,
13879
14069
  messages
@@ -14044,6 +14234,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
14044
14234
  attachInput,
14045
14235
  transcript: renderLog(turns),
14046
14236
  renderCards,
14237
+ renderOptions,
14047
14238
  suggestions: openers,
14048
14239
  call,
14049
14240
  extras,
@@ -16882,6 +17073,21 @@ async function streamReply(args) {
16882
17073
  onCardsEvent(cardsEvent);
16883
17074
  break;
16884
17075
  }
17076
+ case "variant-options": {
17077
+ const data = evt.data;
17078
+ const product = data?.product;
17079
+ if (!product || typeof product.title !== "string" || typeof product.currency !== "string") break;
17080
+ if (!Array.isArray(data.variants) || data.variants.length === 0) break;
17081
+ const options = {
17082
+ product,
17083
+ variants: data.variants
17084
+ };
17085
+ setTurns((prev) => prev.map((t) => t.id === agentTurnId ? {
17086
+ ...t,
17087
+ options
17088
+ } : t));
17089
+ break;
17090
+ }
16885
17091
  case "checkout": {
16886
17092
  const data = evt.data;
16887
17093
  if (!data?.handoffId || !data.url || !data.itemCount) break;
@@ -17066,7 +17272,7 @@ function callStartStamp(spoken, others) {
17066
17272
  * cache makes a second `start()` after `stop()` free).
17067
17273
  */
17068
17274
  async function loadVoiceProtocol() {
17069
- const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-DrpWeT5w.js")]);
17275
+ const [telemetry, chat] = await Promise.all([import("./telemetry-ZeV7hBI7.js"), import("./chat-Bvu3c3dk.js")]);
17070
17276
  return {
17071
17277
  decodeTelemetry: telemetry.decodeTelemetry,
17072
17278
  encodeCallerText: telemetry.encodeCallerText,
@@ -18557,7 +18763,7 @@ function CaptureCardHost({ options }) {
18557
18763
  useEffect(() => {
18558
18764
  let dispose;
18559
18765
  let live = true;
18560
- import("./capture-card-dom-_bYXscCg.js").then(({ mountCaptureCard }) => {
18766
+ import("./capture-card-dom-C0IKjuBA.js").then(({ mountCaptureCard }) => {
18561
18767
  if (live && ref.current) dispose = mountCaptureCard(ref.current, options);
18562
18768
  }).catch(() => void 0);
18563
18769
  return () => {
@@ -19788,7 +19994,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
19788
19994
  const performAct = useCallback(async (event) => {
19789
19995
  const open = openCaptureRef.current;
19790
19996
  if (event.type === "capture-saved") {
19791
- if (open?.card.field !== event.field) return;
19997
+ if (open?.card.field !== event.field || open.card.fields) return;
19792
19998
  if (open.checkout === "more") open.onAnswered("saved");
19793
19999
  else showCaptureCard(null);
19794
20000
  if (open.checkout === void 0) session.markCaptureAnswered("saved");
@@ -19804,7 +20010,8 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
19804
20010
  submit: async (answer) => {
19805
20011
  const status = await session.submitCapture(answer);
19806
20012
  if (status === 404) closedCapturesRef.current.add(options);
19807
- if ("value" in answer) shown = `${event.label} · ${answer.value}`;
20013
+ const label = [event, ...event.fields ?? []].find((detail) => detail.field === answer.field)?.label;
20014
+ if ("value" in answer && status === 200) shown = (shown ? `${shown}\n` : "") + `${label} · ${answer.value}`;
19808
20015
  return status;
19809
20016
  },
19810
20017
  onAnswered: (outcome) => {
@@ -20358,6 +20565,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
20358
20565
  ...turn.delivery ? { delivery: turn.delivery } : {},
20359
20566
  ...turn.shared ? { shared: turn.shared } : {},
20360
20567
  ...turn.cards ? { cards: turn.cards } : {},
20568
+ ...turn.options ? { options: turn.options } : {},
20361
20569
  ...turn.attachments ? { attachments: turn.attachments } : {},
20362
20570
  ...turn.operatorName ? { operatorName: turn.operatorName } : {}
20363
20571
  });
@@ -20443,14 +20651,32 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
20443
20651
  existing.items.push(...event.items);
20444
20652
  if (existing.curationId !== event.curationId) delete existing.curationId;
20445
20653
  }
20654
+ const optionsByTurn = /* @__PURE__ */ new Map();
20655
+ const unboundOptions = [];
20656
+ for (const event of voice.widgetEvents) {
20657
+ if (event.type !== "variant-options") continue;
20658
+ const entry = {
20659
+ stamp: order.stampEvent(event),
20660
+ options: {
20661
+ product: event.product,
20662
+ variants: event.variants
20663
+ }
20664
+ };
20665
+ if (event.turnId === void 0) unboundOptions.push(entry);
20666
+ else optionsByTurn.set(event.turnId, {
20667
+ ...entry,
20668
+ stamp: optionsByTurn.get(event.turnId)?.stamp ?? entry.stamp
20669
+ });
20670
+ }
20446
20671
  const anchors = /* @__PURE__ */ new Map();
20447
20672
  for (const { line, i } of visible) {
20448
20673
  const turnId = line.turnId;
20449
20674
  if (line.speaker !== "agent" || line.filler === true || turnId === void 0) continue;
20450
- if (!byTurn.has(turnId) || anchors.has(turnId)) continue;
20675
+ if (!byTurn.has(turnId) && !optionsByTurn.has(turnId) || anchors.has(turnId)) continue;
20451
20676
  anchors.set(turnId, i);
20452
20677
  }
20453
20678
  const orphaned = [...unbound, ...[...byTurn].filter(([turnId]) => !anchors.has(turnId)).map(([, cards]) => cards)];
20679
+ const orphanedOptions = [...unboundOptions, ...[...optionsByTurn].filter(([turnId]) => !anchors.has(turnId)).map(([, o]) => o)];
20454
20680
  /**
20455
20681
  * ── Why the bound row simply keeps the LINE's stamp ───────────────────
20456
20682
  *
@@ -20488,7 +20714,9 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
20488
20714
  */
20489
20715
  const spoken = visible.map(({ line, i }) => {
20490
20716
  const turnId = line.turnId;
20491
- const bound = turnId !== void 0 && anchors.get(turnId) === i ? byTurn.get(turnId) : void 0;
20717
+ const anchored = turnId !== void 0 && anchors.get(turnId) === i;
20718
+ const bound = anchored ? byTurn.get(turnId) : void 0;
20719
+ const boundOptions = anchored ? optionsByTurn.get(turnId)?.options : void 0;
20492
20720
  return {
20493
20721
  stamp: spokenStamps[i],
20494
20722
  turn: {
@@ -20501,7 +20729,8 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
20501
20729
  ...bound === void 0 ? {} : { cards: {
20502
20730
  ...bound.curationId !== void 0 ? { curationId: bound.curationId } : {},
20503
20731
  items: bound.items
20504
- } }
20732
+ } },
20733
+ ...boundOptions === void 0 ? {} : { options: boundOptions }
20505
20734
  }
20506
20735
  };
20507
20736
  });
@@ -20518,12 +20747,27 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
20518
20747
  }
20519
20748
  }
20520
20749
  }));
20750
+ const renderedOptions = orphanedOptions.map(({ stamp, options }) => ({
20751
+ stamp,
20752
+ turn: {
20753
+ speaker: "agent",
20754
+ text: "",
20755
+ locale,
20756
+ final: true,
20757
+ options
20758
+ }
20759
+ }));
20521
20760
  const callStart = callStartStamp(spoken, [
20522
20761
  ...typed,
20523
20762
  ...rendered,
20763
+ ...renderedOptions,
20524
20764
  ...past.rows
20525
20765
  ]);
20526
- const rows = [...spoken, ...rendered];
20766
+ const rows = [
20767
+ ...spoken,
20768
+ ...rendered,
20769
+ ...renderedOptions
20770
+ ];
20527
20771
  if (callStart !== null) rows.push({
20528
20772
  stamp: callStart,
20529
20773
  turn: {
@@ -20973,4 +21217,4 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
20973
21217
  });
20974
21218
  }
20975
21219
  //#endregion
20976
- 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 };
21220
+ export { IDLE_SNAPSHOT as $, readStoredMinimised as $t, rendererFor as A, formatMessage as An, MARK as At, textDirectionFor as B, KNOT_PATH as Bn, SHEET_PEEK_MAX as Bt, VoiceWidgetWithRenderer as C, oklchToOklab as Cn, DOCK_ALIGN_STORAGE_KEY as Ct, WidgetCartSummary as D, srgbToLinear as Dn, FLOAT_DUCK_DISMISS_MS as Dt, readsAsCheckoutIntent as E, rotateHue as En, DRAG_TAP_SLOP_PX as Et, CallView as F, MARK_VARIANTS as Fn, RADII$1 as Ft, edgeOf as G, bottomLen as Gt, CONCIERGE_POSITIONS as H, BotFace as Hn, SHEET_TUCK as Ht, IDLE_CALL_RECORD as I, WIDGET_AVATARS as In, ROW_H as It, positionClasses as J, persistAlign as Jt, nearestPosition as K, containerAnchor as Kt, WidgetMarkdown as L, WIDGET_IDENTITY_AVATARS as Ln, SHEET_EXPANDED_DESKTOP_MAX as Lt, ShellRenderer as M, widgetMessagesFromCopy as Mn, PILL_H as Mt, deriveWidgetView as N, MorphingLoader as Nn, PILL_MARK as Nt, VariantOptionChips as O, withAlpha as On, FLOAT_GAP as Ot, ConciergeShell as P, DEFAULT_WIDGET_AVATAR as Pn, PROACTIVE_NUDGE_MS as Pt, Mark as Q, readStoredAlign as Qt, parseBlocks as R, dockAvatarFor as Rn, SHEET_EXPANDED_VH as Rt, VoiceWidget as S, oklchToHex as Sn, DESKTOP_WIDTHS as St, readsAsCartViewIntent as T, relativeLuminance as Tn, DRAG_CLICK_WINDOW_MS as Tt, DEFAULT_CONCIERGE_POSITION as U, labelProps as Un, SHORT_VIEWPORT as Ut, ConciergeLauncher as V, RopeKnot as Vn, SHEET_TOP_CLEARANCE as Vt, alignOf as W, cn as Wn, Z_INDEX as Wt, LAUNCHER_VARIANTS as X, pillAnchor as Xt, positionForArrow as Y, persistMinimised as Yt, MARK_STATES as Z, readStored as Zt, useVoiceSession as _, linearToSrgb as _n, BOTTOM_FLOOR as _t, MAX_REPORTED_CART_LINES as a, SHEET_RADIUS_MAX_PX as an, latencyBetween as at, useChatSession as b, oklabToLinearRgb as bn, DESKTOP_BREAKPOINT as bt, deriveCallPhase as c, deriveTheme as cn, deriveDockState as ct, resolveCheckoutUrl as d, themeToMarkedHostCss as dn, CONCIERGE_STATES as dt, rowWidthLen as en, botStateFor as et, toChatCart as f, contrastRatio as fn, deriveConciergeState as ft, createWidgetVoiceTokenFetcher as g, linearRgbToOklab as gn, ACTIVITY_W as gt, ROOM_EVENTS as h, hexToOklch as hn, WIDGET_MESSAGE_MAX_LENGTH as ht, ConciergeWidget as i, CARD_RADIUS_MAX_PX as in, formatMs as it, DockRenderer as j, resolveWidgetMessages as jn, MOBILE_MARGIN as jt, WidgetCardList as k, defaultWidgetMessages as kn, GLASS_IDLE_MS as kt, mergeAddedCartLine as l, themeToCss as ln, deriveDockView as lt, deriveWidgetTheme as m, hexToOklab as mn, formatMoney as mt, CART_LINE_VARIANT_ID_SHAPE as n, snapAlign as nn, SESSION_EVENTS as nt, cartLinesFromSnapshot as o, SYSTEM_FONT_STACK as on, Dock as ot, WidgetThemeScope as p, formatHex as pn, idleConciergeInput as pt, panelClasses as q, geometryVars as qt, ConciergeHost as r, writeStored as rn, SessionLog as rt, chooseOptionsAction as s, WIDGET_THEME_TOKENS as sn, DOCK_STATES as st, CART_LINE_PLATFORM_VARIANT_ID_SHAPE as t, sheetMaxHeightLen as tn, SseFrameParser as tt, resolveAddToCartHandler as u, themeToInlineStyle as un, idleDockInput as ut, CHECKOUT_CAPTURE_REQUIRED as v, mixToward as vn, CONTROL as vt, basketIntentFromTurns as w, parseHex as wn, DOCK_MINIMISED_STORAGE_KEY as wt, detectPage as x, oklabToOklch as xn, DESKTOP_GUTTER as xt, isSameOriginPath as y, oklabToHex as yn, DESKTOP_BOTTOM as yt, stripBidiControls as z, isWidgetAvatar as zn, SHEET_GAP as zt };