@saar-ai/web-widget 0.14.1 → 0.16.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/brand-mark.d.ts +16 -0
- package/dist/brand-mark.d.ts.map +1 -0
- package/dist/chunks/{chat-CrbRIHVN.js → chat-DUERxmYS.js} +8 -1
- package/dist/chunks/{host-widget-DlFlAZYq.js → host-widget-B5F_BxhC.js} +200 -74
- package/dist/concierge-shell.css +1 -1
- package/dist/consent/consent-prompt-dom.d.ts +7 -6
- package/dist/consent/consent-prompt-dom.d.ts.map +1 -1
- package/dist/dock/dock.d.ts +8 -0
- package/dist/dock/dock.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.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +147 -11
- package/dist/messages.d.ts +4 -4
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/theme/derive.d.ts +15 -0
- package/dist/theme/derive.d.ts.map +1 -1
- package/dist/theme/host-tone.d.ts +35 -0
- package/dist/theme/host-tone.d.ts.map +1 -0
- package/dist/use-chat-session.d.ts +17 -16
- package/dist/use-chat-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts.map +1 -1
- package/dist/widget/concierge-shell.d.ts.map +1 -1
- package/dist/widget/shell-renderer.d.ts.map +1 -1
- package/dist/widget.css +1 -1
- package/package.json +3 -3
- package/src/styles/concierge-shell-entry.css +1 -0
- package/src/styles/concierge.css +2 -13
- package/src/styles/cursor.css +45 -0
- package/src/styles/tokens.css +12 -10
- package/src/styles/widget-entry.css +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The product's own colours for the attribution badge, as literal sRGB hex: the
|
|
3
|
+
* marketing `Wordmark` in light mode (rose-500 → amber-400 dot, plum-800 text
|
|
4
|
+
* on white). Never a custom property, because every `--brand-*` the widget
|
|
5
|
+
* sees is the TENANT's skin. `__tests__/brand-mark.test.tsx` pins them to
|
|
6
|
+
* apps/marketing/src/app/icon.svg and packages/ui/src/theme/color-tokens.css.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BRAND_MARK_STOPS: readonly ['#f83e54', '#f3b01d'];
|
|
9
|
+
export declare const BRAND_WORDMARK_COLOR = "#80027c";
|
|
10
|
+
export declare const BRAND_BADGE_PLATE = "#fff";
|
|
11
|
+
/** `plate`: draw the badge's own white pill behind it, for a surface that has none. */
|
|
12
|
+
export declare function BrandWordmark({ name, plate, }: {
|
|
13
|
+
readonly name: string;
|
|
14
|
+
readonly plate?: boolean;
|
|
15
|
+
}): import("react").JSX.Element;
|
|
16
|
+
//# sourceMappingURL=brand-mark.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brand-mark.d.ts","sourceRoot":"","sources":["../src/brand-mark.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,YAAI,SAAS,EAAE,SAAS,CAAU,CAAC;AAChE,eAAO,MAAM,oBAAoB,YAAY,CAAC;AAC9C,eAAO,MAAM,iBAAiB,SAAS,CAAC;AAsBxC,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,KAAK,GACN,EAAE;IACD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B,+BAcA"}
|
|
@@ -645,6 +645,12 @@ var WidgetChatAddToCartEventSchema = object({
|
|
|
645
645
|
* (it arrives ahead of the reply's text on the same stream).
|
|
646
646
|
*/
|
|
647
647
|
var WidgetChatResumedEventSchema = object({ type: literal("resumed") });
|
|
648
|
+
/**
|
|
649
|
+
* The concierge has picked the shopper's message up (SAA-449): the turn has
|
|
650
|
+
* an agent and is about to generate. The widget draws the second tick on the
|
|
651
|
+
* shopper's own bubble from it. Never sent while a person holds the thread.
|
|
652
|
+
*/
|
|
653
|
+
var WidgetChatReadEventSchema = object({ type: literal("read") });
|
|
648
654
|
var WidgetChatDoneEventSchema = object({
|
|
649
655
|
type: literal("done"),
|
|
650
656
|
turnId: string().min(1)
|
|
@@ -665,6 +671,7 @@ var WidgetChatSseEventSchema = discriminatedUnion("type", [
|
|
|
665
671
|
WidgetChatCaptureCardEventSchema,
|
|
666
672
|
WidgetChatFillFormEventSchema,
|
|
667
673
|
WidgetChatResumedEventSchema,
|
|
674
|
+
WidgetChatReadEventSchema,
|
|
668
675
|
WidgetChatDoneEventSchema,
|
|
669
676
|
WidgetChatErrorEventSchema
|
|
670
677
|
]);
|
|
@@ -1112,4 +1119,4 @@ function parseWidgetChatCart(value) {
|
|
|
1112
1119
|
return parsed.success ? parsed.data : null;
|
|
1113
1120
|
}
|
|
1114
1121
|
//#endregion
|
|
1115
|
-
export { CART_LINE_PLATFORM_VARIANT_ID_PATTERN, CART_LINE_VARIANT_ID_PATTERN, DROPPABLE_CARD_FIELDS, MAX_CARDS_PER_EVENT, MAX_CART_LINES, WidgetCartAddFailedReportSchema, WidgetCartAddReportSchema, WidgetChatAddToCartEventSchema, WidgetChatCardSchema, WidgetChatCardsEventSchema, WidgetChatCartLineSchema, WidgetChatCartSchema, WidgetChatCartSourceSchema, WidgetChatCheckoutEventSchema, WidgetChatDoneEventSchema, WidgetChatErrorEventSchema, WidgetChatEscalatedEventSchema, WidgetChatReportSchema, WidgetChatResumedEventSchema, WidgetChatSseEventSchema, WidgetChatTextDeltaEventSchema, WidgetToolEventSchema, WidgetVariantChoiceRequestReportSchema, buildWidgetChatCard, buildWidgetChatCardsEvent, buildWithDroppableFields, extractWidgetToolEvent, parseWidgetChatCart, parseWidgetChatReport };
|
|
1122
|
+
export { CART_LINE_PLATFORM_VARIANT_ID_PATTERN, CART_LINE_VARIANT_ID_PATTERN, DROPPABLE_CARD_FIELDS, MAX_CARDS_PER_EVENT, MAX_CART_LINES, WidgetCartAddFailedReportSchema, WidgetCartAddReportSchema, WidgetChatAddToCartEventSchema, WidgetChatCardSchema, WidgetChatCardsEventSchema, WidgetChatCartLineSchema, WidgetChatCartSchema, WidgetChatCartSourceSchema, WidgetChatCheckoutEventSchema, WidgetChatDoneEventSchema, WidgetChatErrorEventSchema, WidgetChatEscalatedEventSchema, WidgetChatReadEventSchema, WidgetChatReportSchema, WidgetChatResumedEventSchema, WidgetChatSseEventSchema, WidgetChatTextDeltaEventSchema, WidgetToolEventSchema, WidgetVariantChoiceRequestReportSchema, buildWidgetChatCard, buildWidgetChatCardsEvent, buildWithDroppableFields, extractWidgetToolEvent, parseWidgetChatCart, parseWidgetChatReport };
|
|
@@ -4622,8 +4622,9 @@ var defaultWidgetMessages = {
|
|
|
4622
4622
|
capture_saved_event: "Thanks — sent.",
|
|
4623
4623
|
capture_declined_event: "No problem — skipped.",
|
|
4624
4624
|
escalated_banner: "A human teammate will pick this up shortly.",
|
|
4625
|
-
status_sending: "
|
|
4626
|
-
status_sent: "
|
|
4625
|
+
status_sending: "Queued",
|
|
4626
|
+
status_sent: "Delivered",
|
|
4627
|
+
status_read: "Read",
|
|
4627
4628
|
typing: "Typing",
|
|
4628
4629
|
suggestions_label: "Suggested questions",
|
|
4629
4630
|
suggestion_1: "What is popular right now?",
|
|
@@ -5101,12 +5102,13 @@ var SURFACE_GLASS_BLURRED_ALPHA = .25;
|
|
|
5101
5102
|
*
|
|
5102
5103
|
* WHY THIS IS DERIVED and not two static blocks in `styles/tokens.css`.
|
|
5103
5104
|
* That was the cheaper plan and it does not work: nothing sets `.dark` on the
|
|
5104
|
-
* shadow host
|
|
5105
|
-
* `
|
|
5106
|
-
*
|
|
5107
|
-
*
|
|
5108
|
-
*
|
|
5109
|
-
*
|
|
5105
|
+
* shadow host (`core`'s SAA-441 mark is `data-wgt-tone`, which that block
|
|
5106
|
+
* deliberately does not match). `cdn/dock-dom.ts` resolves the tone in
|
|
5107
|
+
* JAVASCRIPT and writes the matching block as an inline `style` attribute —
|
|
5108
|
+
* so `tokens.css`'s `.dark` rules never match the shipped widget, and a
|
|
5109
|
+
* `@media` query there would be right only for `tone: 'auto'` and inverted
|
|
5110
|
+
* for a tenant who pinned `light` or `dark`. The tune has to arrive through
|
|
5111
|
+
* the same channel as the surface it is tuned for.
|
|
5110
5112
|
*
|
|
5111
5113
|
* It is chosen from the SURFACE's own lightness rather than from `color.tone`
|
|
5112
5114
|
* for the same reason {@link deriveText} is: the tone enum says which block
|
|
@@ -5391,14 +5393,37 @@ function block(vars, selector, indent) {
|
|
|
5391
5393
|
* `tone: 'auto'` — a `prefers-color-scheme: dark` override on the same
|
|
5392
5394
|
* selector, exactly as §9.2 requires ("both defined on `:host`").
|
|
5393
5395
|
*
|
|
5396
|
+
* On `:host` the dark block also follows the host page (SAA-441): `core`
|
|
5397
|
+
* marks its shadow host `data-wgt-tone="dark"` or `"light"` from
|
|
5398
|
+
* `theme/host-tone.ts`, so the media query yields to a light mark and the
|
|
5399
|
+
* dark mark applies on a light system. A host nobody marks (the npm mount)
|
|
5400
|
+
* keeps the media query alone. A namespaced attribute, not a `.dark` class:
|
|
5401
|
+
* the host sits in the merchant's DOM, where their own `.dark` rules would
|
|
5402
|
+
* reach it.
|
|
5403
|
+
*
|
|
5394
5404
|
* `:host` is the default because the dock lives in a shadow root; pass a class
|
|
5395
5405
|
* or `:root` for the console preview, which renders in light DOM.
|
|
5396
5406
|
*/
|
|
5397
5407
|
function themeToCss(theme, selector = ":host") {
|
|
5398
5408
|
let css = `${block(theme.light, selector, "")}\n`;
|
|
5399
|
-
if (theme.dark)
|
|
5409
|
+
if (theme.dark) {
|
|
5410
|
+
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`;
|
|
5413
|
+
}
|
|
5400
5414
|
return css;
|
|
5401
5415
|
}
|
|
5416
|
+
var TONE_MARK = "[data-wgt-tone=";
|
|
5417
|
+
/**
|
|
5418
|
+
* For an element that carries its own token block inside the shadow root
|
|
5419
|
+
* (the React dock's `[data-wgt-scope]`): the same marks, one level up, so the
|
|
5420
|
+
* host page's tone beats the media query on that element too. Matches
|
|
5421
|
+
* nothing in light DOM. Empty unless the tone is `auto`.
|
|
5422
|
+
*/
|
|
5423
|
+
function themeToMarkedHostCss(theme, selector) {
|
|
5424
|
+
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`;
|
|
5426
|
+
}
|
|
5402
5427
|
/**
|
|
5403
5428
|
* The theme as a `style` attribute value, for the `core` stage — which paints
|
|
5404
5429
|
* the resting row before any stylesheet, adopted or otherwise, exists.
|
|
@@ -8310,6 +8335,63 @@ function deriveView(state, input) {
|
|
|
8310
8335
|
throw new TypeError(`Unknown dock state: ${JSON.stringify(state)}`);
|
|
8311
8336
|
}
|
|
8312
8337
|
//#endregion
|
|
8338
|
+
//#region src/brand-mark.tsx
|
|
8339
|
+
/**
|
|
8340
|
+
* The product's own colours for the attribution badge, as literal sRGB hex: the
|
|
8341
|
+
* marketing `Wordmark` in light mode (rose-500 → amber-400 dot, plum-800 text
|
|
8342
|
+
* on white). Never a custom property, because every `--brand-*` the widget
|
|
8343
|
+
* sees is the TENANT's skin. `__tests__/brand-mark.test.tsx` pins them to
|
|
8344
|
+
* apps/marketing/src/app/icon.svg and packages/ui/src/theme/color-tokens.css.
|
|
8345
|
+
*/
|
|
8346
|
+
var BRAND_MARK_STOPS = ["#f83e54", "#f3b01d"];
|
|
8347
|
+
var BRAND_WORDMARK_COLOR = "#80027c";
|
|
8348
|
+
var BRAND_BADGE_PLATE = "#fff";
|
|
8349
|
+
var WORDMARK_STYLE = {
|
|
8350
|
+
display: "inline-flex",
|
|
8351
|
+
alignItems: "center",
|
|
8352
|
+
gap: ".4em",
|
|
8353
|
+
fontSize: 20,
|
|
8354
|
+
fontWeight: 600,
|
|
8355
|
+
letterSpacing: "-.025em",
|
|
8356
|
+
color: BRAND_WORDMARK_COLOR,
|
|
8357
|
+
WebkitTextFillColor: BRAND_WORDMARK_COLOR
|
|
8358
|
+
};
|
|
8359
|
+
var PLATED_STYLE = {
|
|
8360
|
+
...WORDMARK_STYLE,
|
|
8361
|
+
background: BRAND_BADGE_PLATE,
|
|
8362
|
+
borderRadius: 99,
|
|
8363
|
+
padding: "2px 10px"
|
|
8364
|
+
};
|
|
8365
|
+
var MARK_STYLE = {
|
|
8366
|
+
width: ".5em",
|
|
8367
|
+
height: ".5em"
|
|
8368
|
+
};
|
|
8369
|
+
/** `plate`: draw the badge's own white pill behind it, for a surface that has none. */
|
|
8370
|
+
function BrandWordmark({ name, plate }) {
|
|
8371
|
+
const id = "wgt-mark" + useId().replace(/\W/g, "");
|
|
8372
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
8373
|
+
style: plate ? PLATED_STYLE : WORDMARK_STYLE,
|
|
8374
|
+
children: [/* @__PURE__ */ jsxs("svg", {
|
|
8375
|
+
"aria-hidden": "true",
|
|
8376
|
+
viewBox: "0 0 32 32",
|
|
8377
|
+
style: MARK_STYLE,
|
|
8378
|
+
children: [/* @__PURE__ */ jsxs("linearGradient", {
|
|
8379
|
+
id,
|
|
8380
|
+
y2: "1",
|
|
8381
|
+
children: [/* @__PURE__ */ jsx("stop", { stopColor: BRAND_MARK_STOPS[0] }), /* @__PURE__ */ jsx("stop", {
|
|
8382
|
+
offset: "1",
|
|
8383
|
+
stopColor: BRAND_MARK_STOPS[1]
|
|
8384
|
+
})]
|
|
8385
|
+
}), /* @__PURE__ */ jsx("circle", {
|
|
8386
|
+
cx: "16",
|
|
8387
|
+
cy: "16",
|
|
8388
|
+
r: "16",
|
|
8389
|
+
fill: `url(#${id})`
|
|
8390
|
+
})]
|
|
8391
|
+
}), name]
|
|
8392
|
+
});
|
|
8393
|
+
}
|
|
8394
|
+
//#endregion
|
|
8313
8395
|
//#region src/dock/dock.tsx
|
|
8314
8396
|
var DEFAULT_COLOR = {
|
|
8315
8397
|
primary: "#4c1d50",
|
|
@@ -8327,7 +8409,7 @@ var DEFAULT_LAYOUT = {
|
|
|
8327
8409
|
};
|
|
8328
8410
|
var INTERRUPT_SEEN_STORAGE_KEY = "wgt_dock_interrupt_seen";
|
|
8329
8411
|
function Dock(props) {
|
|
8330
|
-
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 } = props;
|
|
8412
|
+
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;
|
|
8331
8413
|
const scopeId = useId().replace(/[^a-zA-Z0-9_-]/g, "");
|
|
8332
8414
|
const rootRef = useRef(null);
|
|
8333
8415
|
const rowRef = useRef(null);
|
|
@@ -8369,6 +8451,7 @@ function Dock(props) {
|
|
|
8369
8451
|
persistMinimised(window, next === "pill");
|
|
8370
8452
|
}, [layout.minimised, preview]);
|
|
8371
8453
|
const [sheet, setSheet] = useState("closed");
|
|
8454
|
+
useEffect(() => onShown?.(sheet !== "closed"), [sheet, onShown]);
|
|
8372
8455
|
/**
|
|
8373
8456
|
* The sheet has been open at least once this session — one of the three
|
|
8374
8457
|
* things that retire the greeting placeholder (see `placeholder` below).
|
|
@@ -9220,7 +9303,8 @@ function Dock(props) {
|
|
|
9220
9303
|
*/
|
|
9221
9304
|
const themeCss = useMemo(() => {
|
|
9222
9305
|
const theme = deriveTheme(color, type);
|
|
9223
|
-
|
|
9306
|
+
const scope = `[data-wgt-scope="${scopeId}"]`;
|
|
9307
|
+
return `${themeToCss(theme, ":host")}\n${themeToCss(theme, scope)}\n${themeToMarkedHostCss(theme, scope)}`;
|
|
9224
9308
|
}, [
|
|
9225
9309
|
color,
|
|
9226
9310
|
type,
|
|
@@ -9355,7 +9439,10 @@ function Dock(props) {
|
|
|
9355
9439
|
href: attribution.href,
|
|
9356
9440
|
target: "_blank",
|
|
9357
9441
|
rel: "noopener noreferrer",
|
|
9358
|
-
children:
|
|
9442
|
+
children: /* @__PURE__ */ jsx(BrandWordmark, {
|
|
9443
|
+
name: attribution.name,
|
|
9444
|
+
plate: true
|
|
9445
|
+
})
|
|
9359
9446
|
}) : null,
|
|
9360
9447
|
privacyChoices !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
9361
9448
|
type: "button",
|
|
@@ -11213,25 +11300,29 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11213
11300
|
style: badge == null ? TRANSCRIPT_EDGE_FADE : TRANSCRIPT_EDGE_FADE_WITH_BADGE,
|
|
11214
11301
|
children: /* @__PURE__ */ jsxs("div", {
|
|
11215
11302
|
ref: transcriptContentRef,
|
|
11216
|
-
children: [
|
|
11217
|
-
|
|
11218
|
-
|
|
11219
|
-
|
|
11220
|
-
|
|
11221
|
-
|
|
11222
|
-
|
|
11223
|
-
|
|
11224
|
-
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
|
-
|
|
11228
|
-
|
|
11229
|
-
|
|
11230
|
-
|
|
11231
|
-
|
|
11232
|
-
|
|
11233
|
-
|
|
11234
|
-
|
|
11303
|
+
children: [
|
|
11304
|
+
children,
|
|
11305
|
+
privacyChoices?.slot ? /* @__PURE__ */ jsx("div", { ref: privacyChoices.slot }) : null,
|
|
11306
|
+
typing ? /* @__PURE__ */ jsxs("p", {
|
|
11307
|
+
"data-testid": "widget-typing-indicator",
|
|
11308
|
+
className: "flex items-center gap-1 px-1 py-1 text-[var(--widget-foreground-muted)]",
|
|
11309
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
11310
|
+
className: "sr-only",
|
|
11311
|
+
children: defaultWidgetMessages.typing
|
|
11312
|
+
}), [
|
|
11313
|
+
0,
|
|
11314
|
+
1,
|
|
11315
|
+
2
|
|
11316
|
+
].map((i) => /* @__PURE__ */ jsx("span", {
|
|
11317
|
+
"aria-hidden": "true",
|
|
11318
|
+
className: "h-1.5 w-1.5 animate-bounce rounded-full bg-current motion-reduce:animate-none",
|
|
11319
|
+
style: {
|
|
11320
|
+
animationDelay: `${i * 140}ms`,
|
|
11321
|
+
animationDuration: "1s"
|
|
11322
|
+
}
|
|
11323
|
+
}, i))]
|
|
11324
|
+
}) : null
|
|
11325
|
+
]
|
|
11235
11326
|
})
|
|
11236
11327
|
}),
|
|
11237
11328
|
/* @__PURE__ */ jsx("div", {
|
|
@@ -11347,19 +11438,14 @@ function ConciergeShell({ open, onOpenChange, state, messageArrived = false, lau
|
|
|
11347
11438
|
})
|
|
11348
11439
|
]
|
|
11349
11440
|
}),
|
|
11350
|
-
attribution ? /* @__PURE__ */
|
|
11441
|
+
attribution ? /* @__PURE__ */ jsx("a", {
|
|
11351
11442
|
href: attribution.href,
|
|
11352
11443
|
target: "_blank",
|
|
11353
11444
|
rel: "noopener noreferrer",
|
|
11354
11445
|
"data-testid": "widget-branding",
|
|
11355
|
-
className: cn(FOOTER_PILL, "left-1/2 inline-flex -translate-x-1/2 items-center
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
className: "size-2.5 rounded-full bg-gradient-to-br from-brand-rose to-brand-amber"
|
|
11359
|
-
}), /* @__PURE__ */ jsx("span", {
|
|
11360
|
-
className: "text-brand-plum font-semibold tracking-tight",
|
|
11361
|
-
children: attribution.name
|
|
11362
|
-
})]
|
|
11446
|
+
className: cn(FOOTER_PILL, "left-1/2 inline-flex -translate-x-1/2 items-center whitespace-nowrap", open ? "pointer-events-auto opacity-100" : "pointer-events-none opacity-0"),
|
|
11447
|
+
style: { backgroundColor: BRAND_BADGE_PLATE },
|
|
11448
|
+
children: /* @__PURE__ */ jsx(BrandWordmark, { name: attribution.name })
|
|
11363
11449
|
}) : null,
|
|
11364
11450
|
privacyChoices ? /* @__PURE__ */ jsx("button", {
|
|
11365
11451
|
type: "button",
|
|
@@ -11680,7 +11766,11 @@ function positionFor(dock) {
|
|
|
11680
11766
|
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 }) {
|
|
11681
11767
|
const [restored] = useState(readOpen);
|
|
11682
11768
|
const [open, setOpen] = useState(dock?.initialMinimised === false || restored);
|
|
11683
|
-
|
|
11769
|
+
const onShown = dock?.onShown;
|
|
11770
|
+
useEffect(() => {
|
|
11771
|
+
writeOpen(open);
|
|
11772
|
+
onShown?.(open);
|
|
11773
|
+
}, [open, onShown]);
|
|
11684
11774
|
const onReady = dock?.onReady;
|
|
11685
11775
|
useLayoutEffect(() => {
|
|
11686
11776
|
onReady?.();
|
|
@@ -12788,30 +12878,30 @@ function TranscriptEvent({ event, awaitingReply, messages }) {
|
|
|
12788
12878
|
});
|
|
12789
12879
|
}
|
|
12790
12880
|
/**
|
|
12791
|
-
* The shopper's own
|
|
12792
|
-
*
|
|
12793
|
-
*
|
|
12794
|
-
*
|
|
12795
|
-
*
|
|
12796
|
-
* not ship a tick it cannot back with an observation.
|
|
12797
|
-
*
|
|
12798
|
-
* The state is carried on `data-delivery` as well as in the accessible name
|
|
12799
|
-
* so that the assertion in a test — and any host styling — reads the actual
|
|
12800
|
-
* state rather than matching on a glyph.
|
|
12881
|
+
* The shopper's own message receipt, under their bubble (SAA-449): no tick
|
|
12882
|
+
* while queued, one once the server stored it, two once it was read — see
|
|
12883
|
+
* `ChatTurnDelivery`. The ticks are an SVG and the state is the accessible
|
|
12884
|
+
* name, so the row's text carries no receipt words; `data-delivery` carries
|
|
12885
|
+
* the state for tests and host styling.
|
|
12801
12886
|
*/
|
|
12802
12887
|
function TurnDeliveryStatus({ delivery, messages }) {
|
|
12803
|
-
const
|
|
12804
|
-
return /* @__PURE__ */
|
|
12888
|
+
const key = delivery === "read" ? "status_read" : delivery === "sent" ? "status_sent" : "status_sending";
|
|
12889
|
+
return /* @__PURE__ */ jsx("span", {
|
|
12890
|
+
role: "img",
|
|
12891
|
+
"aria-label": messages[key] ?? defaultWidgetMessages[key],
|
|
12805
12892
|
"data-testid": "widget-turn-status",
|
|
12806
12893
|
"data-delivery": delivery,
|
|
12807
|
-
className:
|
|
12808
|
-
children:
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
|
|
12894
|
+
className: "pt-0.5 pe-0.5 text-[var(--widget-foreground-muted)]",
|
|
12895
|
+
children: delivery !== "sending" ? /* @__PURE__ */ jsx("svg", {
|
|
12896
|
+
viewBox: "0 0 16 10",
|
|
12897
|
+
width: "16",
|
|
12898
|
+
height: "10",
|
|
12899
|
+
fill: "none",
|
|
12900
|
+
stroke: "currentColor",
|
|
12901
|
+
strokeWidth: "1.6",
|
|
12812
12902
|
"aria-hidden": "true",
|
|
12813
|
-
children: delivery === "
|
|
12814
|
-
})
|
|
12903
|
+
children: /* @__PURE__ */ jsx("path", { d: `M1 5l3 3 6-7${delivery === "read" ? "M7 8l6-7" : ""}` })
|
|
12904
|
+
}) : null
|
|
12815
12905
|
});
|
|
12816
12906
|
}
|
|
12817
12907
|
/** 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. */
|
|
@@ -14453,6 +14543,7 @@ function useChatSession(options) {
|
|
|
14453
14543
|
const [connection, setConnection] = useState("idle");
|
|
14454
14544
|
/** See `UseChatSessionResult.deskTyping`. Expiry timer lives in `deskTypingTimerRef`. */
|
|
14455
14545
|
const [deskTyping, setDeskTyping] = useState(false);
|
|
14546
|
+
const [shown, setShown] = useState();
|
|
14456
14547
|
/**
|
|
14457
14548
|
* Counts SESSIONS, not renders — bumped once per successful `bootSession`,
|
|
14458
14549
|
* and by nothing else. A token ROTATION deliberately does not bump it.
|
|
@@ -14739,12 +14830,25 @@ function useChatSession(options) {
|
|
|
14739
14830
|
seq: t.seq,
|
|
14740
14831
|
...t.attachments && t.attachments.length > 0 ? { attachments: t.attachments } : {},
|
|
14741
14832
|
...t.cards && Array.isArray(t.cards.items) && t.cards.items.length > 0 ? { cards: t.cards } : {},
|
|
14742
|
-
...typeof t.operatorName === "string" && t.operatorName !== "" ? { operatorName: t.operatorName } : {}
|
|
14833
|
+
...typeof t.operatorName === "string" && t.operatorName !== "" ? { operatorName: t.operatorName } : {},
|
|
14834
|
+
...t.readAt !== void 0 ? { delivery: t.readAt ? "read" : "sent" } : {}
|
|
14743
14835
|
})) insertBySeq(next, turn);
|
|
14744
14836
|
return next;
|
|
14745
14837
|
});
|
|
14746
14838
|
}, [clearDeskTyping]);
|
|
14747
14839
|
/**
|
|
14840
|
+
* SAA-449: the shopper's delivered bubbles named by `ids` become read — the
|
|
14841
|
+
* one the SSE `read` frame answers, or those whose server turn id the
|
|
14842
|
+
* holder's `desk:read` named. Only ever on the server's word.
|
|
14843
|
+
*/
|
|
14844
|
+
const markRead = useCallback((ids) => {
|
|
14845
|
+
if (!mountedRef.current) return;
|
|
14846
|
+
setTurns((prev) => prev.map((t) => t.delivery === "sent" && ids.includes(t.id.split(":")[0]) ? {
|
|
14847
|
+
...t,
|
|
14848
|
+
delivery: "read"
|
|
14849
|
+
} : t));
|
|
14850
|
+
}, []);
|
|
14851
|
+
/**
|
|
14748
14852
|
* Records the handoff to a human AS AN EVENT IN THE TRANSCRIPT, at the
|
|
14749
14853
|
* point in the thread where it happened, and flips `status`.
|
|
14750
14854
|
*
|
|
@@ -15350,6 +15454,9 @@ function useChatSession(options) {
|
|
|
15350
15454
|
socket.on(DESK_MESSAGE_EVENT, (message) => {
|
|
15351
15455
|
mergeIncoming([message], "push");
|
|
15352
15456
|
});
|
|
15457
|
+
socket.on("desk:read", (payload) => {
|
|
15458
|
+
if (Array.isArray(payload?.ids)) markRead(payload.ids);
|
|
15459
|
+
});
|
|
15353
15460
|
socket.on(DESK_OWNERSHIP_EVENT, (payload) => {
|
|
15354
15461
|
const event = parseDeskOwnershipEvent(payload);
|
|
15355
15462
|
if (!event || !mountedRef.current) return;
|
|
@@ -15376,6 +15483,7 @@ function useChatSession(options) {
|
|
|
15376
15483
|
status,
|
|
15377
15484
|
socketFactory,
|
|
15378
15485
|
mergeIncoming,
|
|
15486
|
+
markRead,
|
|
15379
15487
|
clearDeskTyping,
|
|
15380
15488
|
markHandbackToAi,
|
|
15381
15489
|
markHandoffToHuman,
|
|
@@ -15547,13 +15655,18 @@ function useChatSession(options) {
|
|
|
15547
15655
|
next: "streaming"
|
|
15548
15656
|
});
|
|
15549
15657
|
},
|
|
15658
|
+
onRead: () => markRead([callerTurnId]),
|
|
15550
15659
|
onDone: (turnId) => {
|
|
15551
15660
|
release();
|
|
15552
15661
|
if (!mountedRef.current) return;
|
|
15553
|
-
|
|
15662
|
+
const inId = `${turnId}:in`;
|
|
15663
|
+
setTurns((prev) => prev.filter((t) => t.id !== turnId && t.id !== inId || t.id === agentTurnId).map((t) => t.id === agentTurnId ? {
|
|
15554
15664
|
...t,
|
|
15555
15665
|
id: turnId,
|
|
15556
15666
|
final: true
|
|
15667
|
+
} : t.id === callerTurnId ? {
|
|
15668
|
+
...t,
|
|
15669
|
+
id: inId
|
|
15557
15670
|
} : t));
|
|
15558
15671
|
setStatus((prev) => prev === "escalated" ? prev : "idle");
|
|
15559
15672
|
},
|
|
@@ -15583,7 +15696,8 @@ function useChatSession(options) {
|
|
|
15583
15696
|
fetchImpl,
|
|
15584
15697
|
status,
|
|
15585
15698
|
markHandoffToHuman,
|
|
15586
|
-
markHandbackToAi
|
|
15699
|
+
markHandbackToAi,
|
|
15700
|
+
markRead
|
|
15587
15701
|
]);
|
|
15588
15702
|
useEffect(() => {
|
|
15589
15703
|
if (status === "streaming" || replyInFlightRef.current !== null) return;
|
|
@@ -15817,11 +15931,14 @@ function useChatSession(options) {
|
|
|
15817
15931
|
* synonym for "read" and left the state it exists to express — reached
|
|
15818
15932
|
* them, has not been looked at — unrepresentable.
|
|
15819
15933
|
*
|
|
15820
|
-
* **Read waits for the tab
|
|
15821
|
-
* === 'visible'`
|
|
15822
|
-
*
|
|
15823
|
-
*
|
|
15824
|
-
*
|
|
15934
|
+
* **Read waits for the tab AND the panel (SAA-449).** `document.
|
|
15935
|
+
* visibilityState === 'visible'` with the transcript on screen — the
|
|
15936
|
+
* renderer reports its panel/sheet through `setShown` — is the honest limit
|
|
15937
|
+
* of what a browser can say about the shopper having seen a reply. A closed
|
|
15938
|
+
* panel holds the read until it opens. A host that never calls `setShown`
|
|
15939
|
+
* keeps the tab-only rule. It over-claims (a visible tab in another window,
|
|
15940
|
+
* a shopper who walked away) and this is stated plainly in the field's own
|
|
15941
|
+
* GraphQL description rather than dressed up.
|
|
15825
15942
|
*
|
|
15826
15943
|
* **`final`, not merely present, is what counts — for both.** A streaming
|
|
15827
15944
|
* reply renders as an agent-speaker turn from its FIRST token
|
|
@@ -15849,7 +15966,7 @@ function useChatSession(options) {
|
|
|
15849
15966
|
const reportReceipts = () => {
|
|
15850
15967
|
const delivered = deliveredTurnIdsRef.current;
|
|
15851
15968
|
const read = readTurnIdsRef.current;
|
|
15852
|
-
const visible = isTabVisible();
|
|
15969
|
+
const visible = isTabVisible() && shown !== false;
|
|
15853
15970
|
const kinds = [];
|
|
15854
15971
|
let sawNewDelivery = false;
|
|
15855
15972
|
let sawNewRead = false;
|
|
@@ -15872,7 +15989,11 @@ function useChatSession(options) {
|
|
|
15872
15989
|
if (typeof document === "undefined") return;
|
|
15873
15990
|
document.addEventListener("visibilitychange", reportReceipts);
|
|
15874
15991
|
return () => document.removeEventListener("visibilitychange", reportReceipts);
|
|
15875
|
-
}, [
|
|
15992
|
+
}, [
|
|
15993
|
+
turns,
|
|
15994
|
+
shown,
|
|
15995
|
+
sendClientReceipts
|
|
15996
|
+
]);
|
|
15876
15997
|
const checkout = useCallback(async (items, curationId, cartAttributionToken) => {
|
|
15877
15998
|
const chatToken = chatTokenRef.current;
|
|
15878
15999
|
if (chatToken === void 0 || items.length === 0) return null;
|
|
@@ -16004,6 +16125,7 @@ function useChatSession(options) {
|
|
|
16004
16125
|
submitCapture,
|
|
16005
16126
|
sendEvent,
|
|
16006
16127
|
notifyTyping,
|
|
16128
|
+
setShown,
|
|
16007
16129
|
checkout,
|
|
16008
16130
|
sendAttachment,
|
|
16009
16131
|
markHandoffToHuman,
|
|
@@ -16016,7 +16138,7 @@ function useChatSession(options) {
|
|
|
16016
16138
|
* promise and is trivially unit-testable with a synthetic `ReadableStream`.
|
|
16017
16139
|
*/
|
|
16018
16140
|
async function streamReply(args) {
|
|
16019
|
-
const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onResumed, onDone, onError, isMounted } = args;
|
|
16141
|
+
const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onResumed, onRead, onDone, onError, isMounted } = args;
|
|
16020
16142
|
const reader = body.getReader();
|
|
16021
16143
|
const decoder = new TextDecoder();
|
|
16022
16144
|
const parser = new SseFrameParser();
|
|
@@ -16162,6 +16284,9 @@ async function streamReply(args) {
|
|
|
16162
16284
|
case "resumed":
|
|
16163
16285
|
onResumed();
|
|
16164
16286
|
break;
|
|
16287
|
+
case "read":
|
|
16288
|
+
onRead();
|
|
16289
|
+
break;
|
|
16165
16290
|
case "done":
|
|
16166
16291
|
onDone(evt.data?.turnId ?? agentTurnId);
|
|
16167
16292
|
break;
|
|
@@ -16184,7 +16309,7 @@ async function streamReply(args) {
|
|
|
16184
16309
|
* cache makes a second `start()` after `stop()` free).
|
|
16185
16310
|
*/
|
|
16186
16311
|
async function loadVoiceProtocol() {
|
|
16187
|
-
const [telemetry, chat] = await Promise.all([import("./telemetry-UHSrhVyf.js"), import("./chat-
|
|
16312
|
+
const [telemetry, chat] = await Promise.all([import("./telemetry-UHSrhVyf.js"), import("./chat-DUERxmYS.js")]);
|
|
16188
16313
|
return {
|
|
16189
16314
|
decodeTelemetry: telemetry.decodeTelemetry,
|
|
16190
16315
|
encodeCallerText: telemetry.encodeCallerText,
|
|
@@ -19792,7 +19917,8 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19792
19917
|
...insets !== void 0 ? { insets } : {},
|
|
19793
19918
|
...hold !== void 0 ? { hold } : {},
|
|
19794
19919
|
...audio !== void 0 ? { audio } : {},
|
|
19795
|
-
...onReady !== void 0 ? { onReady } : {}
|
|
19920
|
+
...onReady !== void 0 ? { onReady } : {},
|
|
19921
|
+
onShown: session.setShown
|
|
19796
19922
|
};
|
|
19797
19923
|
return /* @__PURE__ */ jsx(VoiceWidgetWithRenderer, {
|
|
19798
19924
|
renderer,
|
|
@@ -19831,4 +19957,4 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19831
19957
|
});
|
|
19832
19958
|
}
|
|
19833
19959
|
//#endregion
|
|
19834
|
-
export { DOCK_STATES as $, WIDGET_THEME_TOKENS as $t, stripBidiControls as A,
|
|
19960
|
+
export { DOCK_STATES as $, WIDGET_THEME_TOKENS as $t, stripBidiControls as A, RopeKnot as An, SHEET_EXPANDED_VH as At, edgeOf as B, persistAlign as Bt, readsAsCartViewIntent as C, resolveWidgetMessages as Cn, MOBILE_MARGIN as Ct, WidgetCardList as D, WIDGET_AVATARS as Dn, RADII as Dt, WidgetCartSummary as E, DEFAULT_WIDGET_AVATAR as En, PROACTIVE_NUDGE_MS as Et, ConciergeShell as F, SHORT_VIEWPORT as Ft, IDLE_SNAPSHOT as G, readStoredMinimised as Gt, panelClasses as H, pillAnchor as Ht, ConciergeLauncher as I, Z_INDEX as It, SESSION_EVENTS as J, snapAlign as Jt, botStateFor as K, rowWidthLen as Kt, CONCIERGE_POSITIONS as L, bottomLen as Lt, DockRenderer as M, labelProps as Mn, SHEET_PEEK_MAX as Mt, ShellRenderer as N, cn as Nn, SHEET_TOP_CLEARANCE as Nt, WidgetMarkdown as O, isWidgetAvatar as On, ROW_H as Ot, deriveWidgetView as P, SHEET_TUCK as Pt, Dock as Q, SYSTEM_FONT_STACK as Qt, DEFAULT_CONCIERGE_POSITION as R, containerAnchor as Rt, basketIntentFromTurns as S, formatMessage as Sn, MARK as St, textDirectionFor as T, MorphingLoader as Tn, PILL_MARK as Tt, positionClasses as U, readStored as Ut, nearestPosition as V, persistMinimised as Vt, positionForArrow as W, readStoredAlign as Wt, formatMs as X, CARD_RADIUS_MAX_PX as Xt, SessionLog as Y, writeStored as Yt, latencyBetween as Z, SHEET_RADIUS_MAX_PX as Zt, isSameOriginPath as _, relativeLuminance as _n, DRAG_CLICK_WINDOW_MS as _t, MAX_REPORTED_CART_LINES as a, formatHex as an, idleConciergeInput as at, VoiceWidget as b, withAlpha as bn, FLOAT_GAP as bt, deriveCallPhase as c, linearRgbToOklab as cn, ACTIVITY_W as ct, resolveCheckoutUrl as d, oklabToHex as dn, DESKTOP_BOTTOM as dt, deriveTheme as en, deriveDockState as et, toChatCart as f, oklabToLinearRgb as fn, DESKTOP_BREAKPOINT as ft, CHECKOUT_CAPTURE_REQUIRED as g, parseHex as gn, DOCK_MINIMISED_STORAGE_KEY as gt, useVoiceSession as h, oklchToOklab as hn, DOCK_ALIGN_STORAGE_KEY as ht, ConciergeWidget as i, contrastRatio as in, deriveConciergeState as it, rendererFor as j, BotFace as jn, SHEET_GAP as jt, parseBlocks as k, KNOT_PATH as kn, SHEET_EXPANDED_DESKTOP_MAX as kt, mergeAddedCartLine as l, linearToSrgb as ln, BOTTOM_FLOOR as lt, createWidgetVoiceTokenFetcher as m, oklchToHex as mn, DESKTOP_WIDTHS as mt, CART_LINE_VARIANT_ID_SHAPE as n, themeToInlineStyle as nn, idleDockInput as nt, cartLinesFromSnapshot as o, hexToOklab as on, formatMoney as ot, ROOM_EVENTS as p, oklabToOklch as pn, DESKTOP_GUTTER as pt, SseFrameParser as q, sheetMaxHeightLen as qt, ConciergeHost as r, themeToMarkedHostCss as rn, CONCIERGE_STATES as rt, chooseOptionsAction as s, hexToOklch as sn, WIDGET_MESSAGE_MAX_LENGTH as st, CART_LINE_PLATFORM_VARIANT_ID_SHAPE as t, themeToCss as tn, deriveDockView as tt, resolveAddToCartHandler as u, mixToward as un, CONTROL as ut, useChatSession as v, rotateHue as vn, DRAG_TAP_SLOP_PX as vt, readsAsCheckoutIntent as w, widgetMessagesFromCopy as wn, PILL_H as wt, VoiceWidgetWithRenderer as x, defaultWidgetMessages as xn, GLASS_IDLE_MS as xt, detectPage as y, srgbToLinear as yn, FLOAT_DUCK_DISMISS_MS as yt, alignOf as z, geometryVars as zt };
|