@saar-ai/web-widget 0.13.1 → 0.14.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-R7z4DtMM.js → chat-CrbRIHVN.js} +18 -5
- package/dist/chunks/{esm-DSxqq2-d.js → esm-D2iq2DjO.js} +6 -6
- package/dist/chunks/{host-widget-iQ-2t8vu.js → host-widget-BJrw-B0B.js} +347 -135
- package/dist/chunks/{schemas-B2B3k74u.js → schemas-DC_oWrTO.js} +51 -19
- package/dist/chunks/starters-pick-noq7o_W8.js +139 -0
- package/dist/chunks/{telemetry-3f--vvdX.js → telemetry-UHSrhVyf.js} +1 -1
- package/dist/dock/dock-drag.d.ts +0 -2
- package/dist/dock/dock-drag.d.ts.map +1 -1
- package/dist/dock/dock-motion.d.ts +0 -1
- package/dist/dock/dock-motion.d.ts.map +1 -1
- package/dist/dock/dock-state.d.ts +0 -52
- package/dist/dock/dock-state.d.ts.map +1 -1
- package/dist/dock/dock.d.ts +0 -18
- package/dist/dock/dock.d.ts.map +1 -1
- package/dist/generated/widget-css.d.ts.map +1 -1
- package/dist/host-widget.d.ts +9 -1
- package/dist/host-widget.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/messages.d.ts +9 -0
- package/dist/messages.d.ts.map +1 -1
- package/dist/next/index.js +1 -1
- package/dist/starters-pick.d.ts +16 -0
- package/dist/starters-pick.d.ts.map +1 -0
- package/dist/text-direction.d.ts +11 -45
- package/dist/text-direction.d.ts.map +1 -1
- package/dist/use-chat-session.d.ts +63 -13
- package/dist/use-chat-session.d.ts.map +1 -1
- package/dist/voice-widget.d.ts +13 -1
- package/dist/voice-widget.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.css +1 -1
- package/package.json +9 -9
|
@@ -4618,6 +4618,7 @@ var defaultWidgetMessages = {
|
|
|
4618
4618
|
dock_minimise_dock: "Minimise the concierge",
|
|
4619
4619
|
dock_hide_conversation: "Hide conversation",
|
|
4620
4620
|
handoff_event: "Handed to a human teammate",
|
|
4621
|
+
handback_event: "Back with the concierge",
|
|
4621
4622
|
escalated_banner: "A human teammate will pick this up shortly.",
|
|
4622
4623
|
status_sending: "Sending",
|
|
4623
4624
|
status_sent: "Sent",
|
|
@@ -8294,50 +8295,6 @@ function deriveView(state, input) {
|
|
|
8294
8295
|
}
|
|
8295
8296
|
throw new TypeError(`Unknown dock state: ${JSON.stringify(state)}`);
|
|
8296
8297
|
}
|
|
8297
|
-
/**
|
|
8298
|
-
* §3.4 (revised 2026-09-11) — where the LATEST EXCHANGE begins.
|
|
8299
|
-
*
|
|
8300
|
-
* @deprecated Nothing in the dock renders a latest-exchange view any more
|
|
8301
|
-
* (§3.4, revised 2026-09-15). Kept, and still correct, because it is
|
|
8302
|
-
* published API.
|
|
8303
|
-
*
|
|
8304
|
-
* An exchange is the shopper's line and the reply to it. The latest one
|
|
8305
|
-
* therefore starts at the LAST caller turn and runs to the end, so a reply
|
|
8306
|
-
* that arrived as three turns (a filler, the answer, the cards) stays whole.
|
|
8307
|
-
*
|
|
8308
|
-
* Two cases are not that shape and both are real:
|
|
8309
|
-
*
|
|
8310
|
-
* - the shopper has not spoken yet. The concierge opens with a greeting of
|
|
8311
|
-
* its own, and a proactive nudge can add a second line before anybody has
|
|
8312
|
-
* typed; the latest exchange is then the LAST agent turn alone, because
|
|
8313
|
-
* two unanswered agent lines are two things said, not one exchange.
|
|
8314
|
-
* - a `speaker: 'event'` row — §3.4's handoff marker. It is something that
|
|
8315
|
-
* happened TO an exchange rather than a turn in one, so it never starts a
|
|
8316
|
-
* new one and never ends the search for the caller line above it.
|
|
8317
|
-
*/
|
|
8318
|
-
function latestExchangeStart(speakers) {
|
|
8319
|
-
for (let i = speakers.length - 1; i >= 0; i--) if (speakers[i] === "caller") return i;
|
|
8320
|
-
return Math.max(0, speakers.length - 1);
|
|
8321
|
-
}
|
|
8322
|
-
/**
|
|
8323
|
-
* How many exchanges the transcript holds — the number "Show conversation"
|
|
8324
|
-
* was offered on (§3.4: the control existed only when there was more than one).
|
|
8325
|
-
*
|
|
8326
|
-
* @deprecated The control was removed with §3.4's latest-exchange view on
|
|
8327
|
-
* 2026-09-15. Kept, and still correct, because it is published API.
|
|
8328
|
-
*
|
|
8329
|
-
* A caller line opens an exchange; anything said BEFORE the first one (the
|
|
8330
|
-
* greeting, a proactive nudge) is an exchange of its own, because it is
|
|
8331
|
-
* something the shopper can scroll back to and would otherwise be counted as
|
|
8332
|
-
* nothing at all — leaving a dock that shows a greeting, then an answer, and
|
|
8333
|
-
* claims there is nothing more to see.
|
|
8334
|
-
*/
|
|
8335
|
-
function exchangeCount(speakers) {
|
|
8336
|
-
if (speakers.length === 0) return 0;
|
|
8337
|
-
const opened = speakers.findIndex((s) => s === "caller");
|
|
8338
|
-
if (opened === -1) return speakers.length;
|
|
8339
|
-
return speakers.filter((s) => s === "caller").length + (opened === 0 ? 0 : 1);
|
|
8340
|
-
}
|
|
8341
8298
|
//#endregion
|
|
8342
8299
|
//#region src/dock/dock.tsx
|
|
8343
8300
|
var DEFAULT_COLOR = {
|
|
@@ -9858,7 +9815,7 @@ function botStateFor(snapshot) {
|
|
|
9858
9815
|
return "listening";
|
|
9859
9816
|
}
|
|
9860
9817
|
//#endregion
|
|
9861
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9818
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/utils/toKebabCase.mjs
|
|
9862
9819
|
/**
|
|
9863
9820
|
* @license lucide-react v1.50.0 - ISC
|
|
9864
9821
|
*
|
|
@@ -9867,7 +9824,7 @@ function botStateFor(snapshot) {
|
|
|
9867
9824
|
*/
|
|
9868
9825
|
var toKebabCase = (string) => string?.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
9869
9826
|
//#endregion
|
|
9870
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9827
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/utils/toLucideIconData.mjs
|
|
9871
9828
|
/**
|
|
9872
9829
|
* @license lucide-react v1.50.0 - ISC
|
|
9873
9830
|
*
|
|
@@ -9884,7 +9841,7 @@ function toLucideIconData(iconName, iconNode, aliases = []) {
|
|
|
9884
9841
|
};
|
|
9885
9842
|
}
|
|
9886
9843
|
//#endregion
|
|
9887
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9844
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/utils/toCamelCase.mjs
|
|
9888
9845
|
/**
|
|
9889
9846
|
* @license lucide-react v1.50.0 - ISC
|
|
9890
9847
|
*
|
|
@@ -9906,7 +9863,7 @@ var toCamelCase = (string) => {
|
|
|
9906
9863
|
return out;
|
|
9907
9864
|
};
|
|
9908
9865
|
//#endregion
|
|
9909
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9866
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/utils/toPascalCase.mjs
|
|
9910
9867
|
/**
|
|
9911
9868
|
* @license lucide-react v1.50.0 - ISC
|
|
9912
9869
|
*
|
|
@@ -9918,7 +9875,7 @@ var toPascalCase = (string) => {
|
|
|
9918
9875
|
return camelCase.charAt(0).toUpperCase() + camelCase.slice(1);
|
|
9919
9876
|
};
|
|
9920
9877
|
//#endregion
|
|
9921
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9878
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/utils/mergeClasses.mjs
|
|
9922
9879
|
/**
|
|
9923
9880
|
* @license lucide-react v1.50.0 - ISC
|
|
9924
9881
|
*
|
|
@@ -9929,7 +9886,7 @@ var mergeClasses = (...classes) => classes.filter((className, index, array) => {
|
|
|
9929
9886
|
return Boolean(className) && className.trim() !== "" && array.indexOf(className) === index;
|
|
9930
9887
|
}).join(" ").trim();
|
|
9931
9888
|
//#endregion
|
|
9932
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9889
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/build/defaultAttributes.mjs
|
|
9933
9890
|
/**
|
|
9934
9891
|
* @license lucide-react v1.50.0 - ISC
|
|
9935
9892
|
*
|
|
@@ -9948,7 +9905,7 @@ var defaultAttributes = {
|
|
|
9948
9905
|
"stroke-linejoin": "round"
|
|
9949
9906
|
};
|
|
9950
9907
|
//#endregion
|
|
9951
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9908
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconNode.mjs
|
|
9952
9909
|
/**
|
|
9953
9910
|
* @license lucide-react v1.50.0 - ISC
|
|
9954
9911
|
*
|
|
@@ -10003,7 +9960,7 @@ function buildLucideIconNode(icon, params = {}) {
|
|
|
10003
9960
|
];
|
|
10004
9961
|
}
|
|
10005
9962
|
//#endregion
|
|
10006
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9963
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/build/buildLucideIconForReact.mjs
|
|
10007
9964
|
/**
|
|
10008
9965
|
* @license lucide-react v1.50.0 - ISC
|
|
10009
9966
|
*
|
|
@@ -10024,7 +9981,7 @@ function buildLucideIconForReact(icon, params = {}) {
|
|
|
10024
9981
|
});
|
|
10025
9982
|
}
|
|
10026
9983
|
//#endregion
|
|
10027
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9984
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/shared/src/utils/hasA11yProp.mjs
|
|
10028
9985
|
/**
|
|
10029
9986
|
* @license lucide-react v1.50.0 - ISC
|
|
10030
9987
|
*
|
|
@@ -10036,7 +9993,7 @@ var hasA11yProp = (props) => {
|
|
|
10036
9993
|
return false;
|
|
10037
9994
|
};
|
|
10038
9995
|
//#endregion
|
|
10039
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
9996
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/context.mjs
|
|
10040
9997
|
/**
|
|
10041
9998
|
* @license lucide-react v1.50.0 - ISC
|
|
10042
9999
|
*
|
|
@@ -10046,7 +10003,7 @@ var hasA11yProp = (props) => {
|
|
|
10046
10003
|
var LucideContext = createContext({});
|
|
10047
10004
|
var useLucideContext = () => useContext(LucideContext);
|
|
10048
10005
|
//#endregion
|
|
10049
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10006
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/Icon.mjs
|
|
10050
10007
|
/**
|
|
10051
10008
|
* @license lucide-react v1.50.0 - ISC
|
|
10052
10009
|
*
|
|
@@ -10077,7 +10034,7 @@ var Icon = forwardRef(({ color, size, width, height, strokeWidth, absoluteStroke
|
|
|
10077
10034
|
}, [...builtIconNode.map(([tag, attrs]) => createElement(tag, attrs)), ...Array.isArray(children) ? children : [children]]);
|
|
10078
10035
|
});
|
|
10079
10036
|
//#endregion
|
|
10080
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10037
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/createLucideIcon.mjs
|
|
10081
10038
|
/**
|
|
10082
10039
|
* @license lucide-react v1.50.0 - ISC
|
|
10083
10040
|
*
|
|
@@ -10096,7 +10053,7 @@ function createLucideIcon(iconDataOrName, iconNode = [], aliases = []) {
|
|
|
10096
10053
|
return Component;
|
|
10097
10054
|
}
|
|
10098
10055
|
//#endregion
|
|
10099
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10056
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/grip-vertical.mjs
|
|
10100
10057
|
/**
|
|
10101
10058
|
* @license lucide-react v1.50.0 - ISC
|
|
10102
10059
|
*
|
|
@@ -10148,7 +10105,7 @@ var __iconData$6 = {
|
|
|
10148
10105
|
__iconData$6.node;
|
|
10149
10106
|
var GripVertical = createLucideIcon(__iconData$6);
|
|
10150
10107
|
//#endregion
|
|
10151
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10108
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/mic-off.mjs
|
|
10152
10109
|
/**
|
|
10153
10110
|
* @license lucide-react v1.50.0 - ISC
|
|
10154
10111
|
*
|
|
@@ -10188,7 +10145,7 @@ var __iconData$5 = {
|
|
|
10188
10145
|
__iconData$5.node;
|
|
10189
10146
|
var MicOff = createLucideIcon(__iconData$5);
|
|
10190
10147
|
//#endregion
|
|
10191
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10148
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/mic.mjs
|
|
10192
10149
|
/**
|
|
10193
10150
|
* @license lucide-react v1.50.0 - ISC
|
|
10194
10151
|
*
|
|
@@ -10220,7 +10177,7 @@ var __iconData$4 = {
|
|
|
10220
10177
|
__iconData$4.node;
|
|
10221
10178
|
var Mic = createLucideIcon(__iconData$4);
|
|
10222
10179
|
//#endregion
|
|
10223
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10180
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/phone-off.mjs
|
|
10224
10181
|
/**
|
|
10225
10182
|
* @license lucide-react v1.50.0 - ISC
|
|
10226
10183
|
*
|
|
@@ -10248,7 +10205,7 @@ var __iconData$3 = {
|
|
|
10248
10205
|
__iconData$3.node;
|
|
10249
10206
|
var PhoneOff = createLucideIcon(__iconData$3);
|
|
10250
10207
|
//#endregion
|
|
10251
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10208
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/send.mjs
|
|
10252
10209
|
/**
|
|
10253
10210
|
* @license lucide-react v1.50.0 - ISC
|
|
10254
10211
|
*
|
|
@@ -10269,7 +10226,7 @@ var __iconData$2 = {
|
|
|
10269
10226
|
__iconData$2.node;
|
|
10270
10227
|
var Send = createLucideIcon(__iconData$2);
|
|
10271
10228
|
//#endregion
|
|
10272
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10229
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/square.mjs
|
|
10273
10230
|
/**
|
|
10274
10231
|
* @license lucide-react v1.50.0 - ISC
|
|
10275
10232
|
*
|
|
@@ -10291,7 +10248,7 @@ var __iconData$1 = {
|
|
|
10291
10248
|
__iconData$1.node;
|
|
10292
10249
|
var Square = createLucideIcon(__iconData$1);
|
|
10293
10250
|
//#endregion
|
|
10294
|
-
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.
|
|
10251
|
+
//#region ../../node_modules/.pnpm/lucide-react@1.50.0_@types+react@19.3.0_react@19.3.1/node_modules/lucide-react/dist/esm/icons/x.mjs
|
|
10295
10252
|
/**
|
|
10296
10253
|
* @license lucide-react v1.50.0 - ISC
|
|
10297
10254
|
*
|
|
@@ -11657,7 +11614,7 @@ function positionFor(dock) {
|
|
|
11657
11614
|
const align = dock?.layout?.desktopAlign;
|
|
11658
11615
|
return align === "left" || align === "right" ? `bottom-${align}` : DEFAULT_CONCIERGE_POSITION;
|
|
11659
11616
|
}
|
|
11660
|
-
function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndCall, statusKind, statusLine, escalated, operatorName, humanTyping, composing, channel, draft, onDraftChange, submit, attaching, onAttach, attachInput, transcript, extras, messages, skinStyle, avatar, attribution, privacyChoices, voice: derivedVoice, dock }) {
|
|
11617
|
+
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 }) {
|
|
11661
11618
|
const [open, setOpen] = useState(dock?.initialMinimised === false);
|
|
11662
11619
|
const onReady = dock?.onReady;
|
|
11663
11620
|
useLayoutEffect(() => {
|
|
@@ -11680,6 +11637,13 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11680
11637
|
const voiceUnavailable = showMic && escalated ? messages.voice_unavailable_escalated : void 0;
|
|
11681
11638
|
const lastTurn = turns[turns.length - 1];
|
|
11682
11639
|
/**
|
|
11640
|
+
* The foot row's dots — only for a composing state the transcript does NOT
|
|
11641
|
+
* already draw (SAA-420). A human composing has its own bubble in the
|
|
11642
|
+
* transcript, and an open concierge turn draws its own dots (or its text as
|
|
11643
|
+
* it streams); counting either here put a second indicator under the first.
|
|
11644
|
+
*/
|
|
11645
|
+
const footComposing = composing && !humanTyping && !replyStreaming;
|
|
11646
|
+
/**
|
|
11683
11647
|
* The SAME state machine the dock runs (docs/CONCIERGE_GENERATIONS.md §2:
|
|
11684
11648
|
* one state, two presentations). `Dock` builds a `DockStateInput` from its
|
|
11685
11649
|
* props and calls `deriveDockState`; this is that, in the widget's terms.
|
|
@@ -11722,7 +11686,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11722
11686
|
shelfCount: dock?.shelf?.items.length ?? 0,
|
|
11723
11687
|
hasTranscript: turns.length > 0,
|
|
11724
11688
|
channel,
|
|
11725
|
-
composing,
|
|
11689
|
+
composing: footComposing,
|
|
11726
11690
|
...operatorName !== void 0 ? { operatorLine: operatorName } : {},
|
|
11727
11691
|
...dock?.copy?.offlineMessage !== void 0 ? { offlineMessage: dock.copy.offlineMessage } : {},
|
|
11728
11692
|
...statusLine !== void 0 && statusLine !== "" ? {
|
|
@@ -11742,7 +11706,7 @@ function ShellRenderer({ turns, showMic, callPhase, micOpen, onToggleMic, onEndC
|
|
|
11742
11706
|
dock,
|
|
11743
11707
|
turns.length,
|
|
11744
11708
|
channel,
|
|
11745
|
-
|
|
11709
|
+
footComposing,
|
|
11746
11710
|
operatorName,
|
|
11747
11711
|
statusLine,
|
|
11748
11712
|
statusKind
|
|
@@ -12531,54 +12495,58 @@ function CheckoutButton({ onCheckout, navigate, messages }) {
|
|
|
12531
12495
|
}) : null] });
|
|
12532
12496
|
}
|
|
12533
12497
|
//#endregion
|
|
12534
|
-
//#region
|
|
12498
|
+
//#region ../widget-protocol/dist/text-direction.js
|
|
12535
12499
|
/**
|
|
12536
12500
|
* Base direction for a block of text whose language is the CONTENT's, not the
|
|
12537
|
-
* reader's.
|
|
12538
|
-
*
|
|
12539
|
-
*
|
|
12540
|
-
*
|
|
12541
|
-
*
|
|
12542
|
-
*
|
|
12543
|
-
*
|
|
12544
|
-
*
|
|
12545
|
-
*
|
|
12546
|
-
*
|
|
12547
|
-
*
|
|
12548
|
-
*
|
|
12549
|
-
*
|
|
12550
|
-
*
|
|
12551
|
-
*
|
|
12552
|
-
*
|
|
12553
|
-
*
|
|
12554
|
-
*
|
|
12555
|
-
*
|
|
12556
|
-
* the
|
|
12501
|
+
* reader's. Pure, string-only and dependency-free: a STATIC import into the
|
|
12502
|
+
* chat bundle a shopper downloads, shared by the console (`apps/web`) and the
|
|
12503
|
+
* widget (`@saar-ai/web-widget`), which used to keep a hand copy each.
|
|
12504
|
+
*
|
|
12505
|
+
* It lives here rather than in `@wesence/i18n` because the widget's published
|
|
12506
|
+
* bundle may resolve no `@wesence/*` module at all (`docs/PACKAGE_DISTRIBUTION.md`,
|
|
12507
|
+
* enforced by `scripts/check-npm-bundle-provenance.mjs`), the same reason
|
|
12508
|
+
* `./money` lives here.
|
|
12509
|
+
*
|
|
12510
|
+
* ## Why the console's own direction is the wrong answer
|
|
12511
|
+
*
|
|
12512
|
+
* `<html dir>` is set from the operator's UI locale, and every element inherits
|
|
12513
|
+
* it. That is right for the chrome and wrong for a transcript: an
|
|
12514
|
+
* English-speaking agent reading an Arabic conversation would render each
|
|
12515
|
+
* message with an LTR base direction, and the Unicode bidirectional algorithm
|
|
12516
|
+
* would then lay out the runs in the wrong order and throw trailing punctuation
|
|
12517
|
+
* to the wrong end of the line.
|
|
12518
|
+
*
|
|
12519
|
+
* The failure is invisible to the person looking at it. An agent who cannot read
|
|
12520
|
+
* Arabic sees Arabic-looking text and moves on; the customer is the one who gets
|
|
12521
|
+
* quoted back a sentence that reads incorrectly. The reverse case is just as
|
|
12522
|
+
* real — an Arabic-speaking agent reading English conversations under an RTL
|
|
12523
|
+
* base.
|
|
12557
12524
|
*
|
|
12558
12525
|
* ## Mixed runs are the normal case here, not an edge case
|
|
12559
12526
|
*
|
|
12560
12527
|
* Verified against live recognition output: Arabic comes back as
|
|
12561
12528
|
* `رقم الـ order هو 4471. Please check من فضلك.` and Hindi as
|
|
12562
|
-
* `मेरा order number 4471 है।`. Latin nouns inside a non-Latin sentence are
|
|
12563
|
-
*
|
|
12564
|
-
*
|
|
12529
|
+
* `मेरा order number 4471 है।`. Latin nouns inside a non-Latin sentence are what
|
|
12530
|
+
* this product's transcripts actually contain, so bidirectional layout is
|
|
12531
|
+
* exercised on ordinary traffic rather than by an unusual customer.
|
|
12565
12532
|
*
|
|
12566
12533
|
* ## `auto` is the floor, not the goal
|
|
12567
12534
|
*
|
|
12568
12535
|
* With a known language this returns a definite direction. Without one it
|
|
12569
12536
|
* returns `auto`, which delegates to the browser's first-strong-character
|
|
12570
|
-
* heuristic — better than inheriting the
|
|
12571
|
-
*
|
|
12572
|
-
*
|
|
12537
|
+
* heuristic — better than inheriting the chrome, but wrong for a message that
|
|
12538
|
+
* opens with an English word and continues in Arabic (`Please check من فضلك`).
|
|
12539
|
+
* The real fix is to persist the conversation's resolved locale and pass it in;
|
|
12540
|
+
* see the note in `Transcript`.
|
|
12573
12541
|
*/
|
|
12574
12542
|
/**
|
|
12575
12543
|
* Languages written right-to-left. Keyed on the language subtag, so a region
|
|
12576
12544
|
* never has to be enumerated.
|
|
12577
12545
|
*
|
|
12578
|
-
* Beyond Arabic on purpose: Hebrew, Farsi, Urdu and Pashto are scripts
|
|
12579
|
-
*
|
|
12580
|
-
*
|
|
12581
|
-
*
|
|
12546
|
+
* Beyond Arabic on purpose: Hebrew, Farsi, Urdu and Pashto are the scripts a CX
|
|
12547
|
+
* product in this region acquires next, and getting one wrong is the same silent
|
|
12548
|
+
* failure. Adding a language to the product must not also require remembering
|
|
12549
|
+
* this file.
|
|
12582
12550
|
*/
|
|
12583
12551
|
var RTL_LANGUAGES = new Set([
|
|
12584
12552
|
"ar",
|
|
@@ -12617,11 +12585,11 @@ var LANGUAGE_SUBTAG = /^[a-z]{2,3}$/;
|
|
|
12617
12585
|
/**
|
|
12618
12586
|
* The base direction for text in `locale`.
|
|
12619
12587
|
*
|
|
12620
|
-
* @param locale BCP-47 tag
|
|
12621
|
-
*
|
|
12622
|
-
*
|
|
12588
|
+
* @param locale BCP-47 tag from stored conversation data — untyped by the time
|
|
12589
|
+
* it reaches here, so anything malformed resolves to `auto` rather than to a
|
|
12590
|
+
* guess.
|
|
12623
12591
|
*/
|
|
12624
|
-
function textDirectionFor(locale) {
|
|
12592
|
+
function textDirectionFor$1(locale) {
|
|
12625
12593
|
if (locale === void 0 || locale === null || locale === "") return "auto";
|
|
12626
12594
|
const language = locale.toLowerCase().split("-")[0] ?? "";
|
|
12627
12595
|
if (!LANGUAGE_SUBTAG.test(language)) return "auto";
|
|
@@ -12630,6 +12598,9 @@ function textDirectionFor(locale) {
|
|
|
12630
12598
|
return "auto";
|
|
12631
12599
|
}
|
|
12632
12600
|
//#endregion
|
|
12601
|
+
//#region src/text-direction.ts
|
|
12602
|
+
var textDirectionFor = textDirectionFor$1;
|
|
12603
|
+
//#endregion
|
|
12633
12604
|
//#region src/voice-widget.tsx
|
|
12634
12605
|
/**
|
|
12635
12606
|
* The "still composing" affordance, shown in the agent's own bubble from the
|
|
@@ -12694,10 +12665,11 @@ function TypingDots({ label }) {
|
|
|
12694
12665
|
* it twice would be worse than announcing it once.
|
|
12695
12666
|
*/
|
|
12696
12667
|
function TranscriptEvent({ event, awaitingReply, messages }) {
|
|
12697
|
-
if (event !== "handoff") return null;
|
|
12668
|
+
if (event !== "handoff" && event !== "handback") return null;
|
|
12669
|
+
const handback = event === "handback";
|
|
12698
12670
|
return /* @__PURE__ */ jsxs("div", {
|
|
12699
12671
|
className: "wgt-turn-row flex flex-col items-center gap-1 py-1",
|
|
12700
|
-
"data-testid": "widget-handoff-event",
|
|
12672
|
+
"data-testid": handback ? "widget-handback-event" : "widget-handoff-event",
|
|
12701
12673
|
"data-dock-follow": "",
|
|
12702
12674
|
children: [/* @__PURE__ */ jsxs("p", {
|
|
12703
12675
|
className: "flex w-full items-center gap-3 text-[11px] font-medium tracking-wide text-[var(--widget-foreground-muted)] [&:lang(ar)]:tracking-normal [&:lang(hi)]:tracking-normal",
|
|
@@ -12706,13 +12678,13 @@ function TranscriptEvent({ event, awaitingReply, messages }) {
|
|
|
12706
12678
|
"aria-hidden": "true",
|
|
12707
12679
|
className: "h-px flex-1 bg-[var(--widget-foreground-muted)]/25"
|
|
12708
12680
|
}),
|
|
12709
|
-
/* @__PURE__ */ jsx("span", { children: messages.handoff_event ?? defaultWidgetMessages.handoff_event }),
|
|
12681
|
+
/* @__PURE__ */ jsx("span", { children: handback ? messages.handback_event ?? defaultWidgetMessages.handback_event : messages.handoff_event ?? defaultWidgetMessages.handoff_event }),
|
|
12710
12682
|
/* @__PURE__ */ jsx("span", {
|
|
12711
12683
|
"aria-hidden": "true",
|
|
12712
12684
|
className: "h-px flex-1 bg-[var(--widget-foreground-muted)]/25"
|
|
12713
12685
|
})
|
|
12714
12686
|
]
|
|
12715
|
-
}), awaitingReply ? /* @__PURE__ */ jsx("p", {
|
|
12687
|
+
}), awaitingReply && !handback ? /* @__PURE__ */ jsx("p", {
|
|
12716
12688
|
role: "status",
|
|
12717
12689
|
"data-testid": "widget-handoff-pending",
|
|
12718
12690
|
className: "text-center text-[11px] text-[var(--widget-foreground-muted)]",
|
|
@@ -12939,7 +12911,7 @@ function VoiceWidget({ renderer, generation, ...props }) {
|
|
|
12939
12911
|
});
|
|
12940
12912
|
}
|
|
12941
12913
|
/** `VoiceWidget` with the renderer decided — the component the CDN entries and `ConciergeHost` use. */
|
|
12942
|
-
function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCall, callPhase = "idle", onSendText, micOpen, status, statusKind, notice, mode = "voice", escalated = false, humanTyping = false, onTyping, onAddToCart, onChooseOptions, chooseOptionsBusy = false, curationHref, productHref, onAttachFile, cart, captureCard, messages = defaultWidgetMessages, navigate, locale = "en", skinStyle, avatar, attribution, privacyChoices, dock }) {
|
|
12914
|
+
function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCall, callPhase = "idle", onSendText, micOpen, status, statusKind, notice, mode = "voice", escalated = false, humanTyping = false, onTyping, onAddToCart, onChooseOptions, chooseOptionsBusy = false, curationHref, productHref, onAttachFile, cart, captureCard, messages = defaultWidgetMessages, suggestions, navigate, locale = "en", skinStyle, avatar, attribution, privacyChoices, dock }) {
|
|
12943
12915
|
const [draft, setDraft] = useState("");
|
|
12944
12916
|
const [sending, setSending] = useState(false);
|
|
12945
12917
|
/** Roomy mode — see the expand control in the header. Collapses back on close, so a reopened widget starts small. */
|
|
@@ -13044,7 +13016,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13044
13016
|
}) : shown.map((turn, i) => turn.speaker === "event" ? /* @__PURE__ */ jsx(TranscriptEvent, {
|
|
13045
13017
|
event: turn.event,
|
|
13046
13018
|
messages,
|
|
13047
|
-
awaitingReply: !shown.slice(i + 1).some((t) => t.speaker === "agent" && t.text.trim() !== "")
|
|
13019
|
+
awaitingReply: !shown.slice(i + 1).some((t) => t.speaker === "event" || t.speaker === "agent" && t.text.trim() !== "")
|
|
13048
13020
|
}, `event-${i}`) : /* @__PURE__ */ jsxs("div", {
|
|
13049
13021
|
"data-dock-follow": "",
|
|
13050
13022
|
className: turn.speaker === "caller" ? "wgt-turn-row flex flex-col items-end" : "wgt-turn-row flex flex-col items-start",
|
|
@@ -13055,7 +13027,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13055
13027
|
className: "px-1 pb-0.5 text-[11px] font-medium text-[var(--widget-foreground-muted)]",
|
|
13056
13028
|
children: turn.operatorName
|
|
13057
13029
|
}) : null,
|
|
13058
|
-
turn.text !== "" || turn.speaker === "agent" && turn.final === false ? /* @__PURE__ */ jsx("div", {
|
|
13030
|
+
turn.text !== "" || turn.speaker === "agent" && turn.final === false && !humanTyping ? /* @__PURE__ */ jsx("div", {
|
|
13059
13031
|
dir: textDirectionFor(turn.locale),
|
|
13060
13032
|
lang: turn.locale,
|
|
13061
13033
|
"data-testid": turn.speaker === "caller" ? "widget-turn-caller" : turn.filler === true ? "widget-turn-agent-filler" : "widget-turn-agent",
|
|
@@ -13111,14 +13083,14 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13111
13083
|
"aria-label": messages.suggestions_label,
|
|
13112
13084
|
"data-testid": "widget-suggestions",
|
|
13113
13085
|
className: "flex flex-wrap gap-2 pt-1",
|
|
13114
|
-
children: SUGGESTION_KEYS.map((key) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
13086
|
+
children: (suggestions ?? SUGGESTION_KEYS.map((key) => messages[key])).map((text) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("button", {
|
|
13115
13087
|
type: "button",
|
|
13116
13088
|
"data-testid": "widget-suggestion",
|
|
13117
13089
|
disabled: sending,
|
|
13118
|
-
onClick: () => void sendSuggestion(
|
|
13090
|
+
onClick: () => void sendSuggestion(text),
|
|
13119
13091
|
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)] disabled:cursor-default disabled:opacity-50 focus-visible:ring-2 focus-visible:ring-[var(--widget-accent-ring)] focus-visible:outline-none",
|
|
13120
|
-
children:
|
|
13121
|
-
}) },
|
|
13092
|
+
children: text
|
|
13093
|
+
}) }, text))
|
|
13122
13094
|
}) : null
|
|
13123
13095
|
]
|
|
13124
13096
|
});
|
|
@@ -13232,6 +13204,7 @@ function VoiceWidgetWithRenderer({ renderer, state, turns, onToggleMic, onEndCal
|
|
|
13232
13204
|
lastTurn,
|
|
13233
13205
|
operatorName,
|
|
13234
13206
|
composing,
|
|
13207
|
+
replyStreaming,
|
|
13235
13208
|
channel,
|
|
13236
13209
|
mode,
|
|
13237
13210
|
showMic,
|
|
@@ -13964,6 +13937,62 @@ new RegExp(`^${LOCALE_PREFIX}/cart(?:/.*)?$`, "i");
|
|
|
13964
13937
|
*/
|
|
13965
13938
|
var DESK_TYPING_INDICATOR_TTL_MS = 6e3;
|
|
13966
13939
|
//#endregion
|
|
13940
|
+
//#region ../widget-protocol/dist/desk-ownership.js
|
|
13941
|
+
/**
|
|
13942
|
+
* `desk:ownership` — the widget room event that tells a visitor who holds
|
|
13943
|
+
* their conversation now: the concierge (`'ai'`) or the human desk
|
|
13944
|
+
* (`'human'`).
|
|
13945
|
+
*
|
|
13946
|
+
* The api emits it into the conversation's widget room every time the desk
|
|
13947
|
+
* moves the conversation (`DeskAssignmentService.move` →
|
|
13948
|
+
* `WidgetRealtimeBridge.publishOwnership`): a claim or takeover says
|
|
13949
|
+
* `'human'`, a release to a queue says `'human'` too (a person, not the AI,
|
|
13950
|
+
* picks it up next), and a hand-back says `'ai'`. The widget
|
|
13951
|
+
* (`@saar-ai/web-widget`'s `useChatSession`) reacts to `'ai'` by leaving the
|
|
13952
|
+
* escalated state — the handoff banner clears and a "back with the
|
|
13953
|
+
* concierge" divider lands in the transcript — and to `'human'` by showing
|
|
13954
|
+
* the handoff divider if it is not already on screen.
|
|
13955
|
+
*
|
|
13956
|
+
* Before this event existed a hand-back told the visitor nothing: the
|
|
13957
|
+
* widget room carried only `desk:message` and `desk:typing`, so the widget
|
|
13958
|
+
* stayed "escalated" and kept promising a human would pick up a conversation
|
|
13959
|
+
* the AI was already answering again. A push can be missed (no socket yet, a
|
|
13960
|
+
* dropped connection), so the AI's first reply after a release also carries
|
|
13961
|
+
* an SSE `resumed` event (`./chat.ts`) — the fallback for the same fact.
|
|
13962
|
+
*
|
|
13963
|
+
* ## Zod-free on purpose
|
|
13964
|
+
*
|
|
13965
|
+
* `@saar-ai/web-widget` imports this subpath STATICALLY into its chat bundle,
|
|
13966
|
+
* which `tools/check-bundle-budget.mjs` forbids zod in — the same reason
|
|
13967
|
+
* `./desk-typing.ts` is schema-free. {@link parseDeskOwnershipEvent} is the
|
|
13968
|
+
* hand-written guard instead: the payload is two fields, and a wrong one is
|
|
13969
|
+
* dropped rather than repaired.
|
|
13970
|
+
*
|
|
13971
|
+
* ## Content-free
|
|
13972
|
+
*
|
|
13973
|
+
* Like `desk:typing`, the payload names no person — no user id, no name. Who
|
|
13974
|
+
* the operator is reaches the visitor only on a reply they wrote, through the
|
|
13975
|
+
* `handoff.showOperatorName` gate. A takeover must not leak a name that gate
|
|
13976
|
+
* would have withheld.
|
|
13977
|
+
*/
|
|
13978
|
+
/** The Socket.IO event name. Both the api and the widget use exactly this string. */
|
|
13979
|
+
var DESK_OWNERSHIP_EVENT = "desk:ownership";
|
|
13980
|
+
/**
|
|
13981
|
+
* The payload, or `null` when it is not one. Returns a fresh object holding
|
|
13982
|
+
* only the two contract fields, so an extra field a newer api adds cannot
|
|
13983
|
+
* ride into the widget's state.
|
|
13984
|
+
*/
|
|
13985
|
+
function parseDeskOwnershipEvent(value) {
|
|
13986
|
+
if (typeof value !== "object" || value === null) return null;
|
|
13987
|
+
const { to, at } = value;
|
|
13988
|
+
if (to !== "ai" && to !== "human") return null;
|
|
13989
|
+
if (typeof at !== "string" || at === "") return null;
|
|
13990
|
+
return {
|
|
13991
|
+
to,
|
|
13992
|
+
at
|
|
13993
|
+
};
|
|
13994
|
+
}
|
|
13995
|
+
//#endregion
|
|
13967
13996
|
//#region src/use-chat-session.ts
|
|
13968
13997
|
/**
|
|
13969
13998
|
* The RUNTIME twin of `@saar-ai/widget-protocol`'s `SameOriginPathSchema`,
|
|
@@ -14037,15 +14066,28 @@ var DEFAULT_API_BASE = "";
|
|
|
14037
14066
|
var DEFAULT_POLL_INTERVAL_MS = 4e3;
|
|
14038
14067
|
/** Poll cadence once the socket is connected — a safety net, not a second primary channel. See the module doc comment. */
|
|
14039
14068
|
var DEFAULT_IDLE_POLL_INTERVAL_MS = 3e4;
|
|
14069
|
+
/** The light poll's cadence before escalation — see `lightPollIntervalMs`. */
|
|
14070
|
+
var DEFAULT_LIGHT_POLL_INTERVAL_MS = 3e4;
|
|
14071
|
+
/**
|
|
14072
|
+
* How long a seq the poll skipped over is still asked for. An operator reply
|
|
14073
|
+
* held in its undo window has its seq from the moment it is written but is
|
|
14074
|
+
* hidden from the poll until the hold ends (at most 60 s,
|
|
14075
|
+
* `MAX_UNDO_WINDOW_SECONDS`, plus the outbound processor's lag), so a later,
|
|
14076
|
+
* visible seq can overtake it. See "Only a POLL result moves the poll cursor".
|
|
14077
|
+
*/
|
|
14078
|
+
var SEQ_GAP_HOLD_MS = 12e4;
|
|
14040
14079
|
/** `socket.io-client`'s `path` default — kept in sync with `apps/api/src/config/config.ts`'s `WIDGET_SOCKET_PATH` default. */
|
|
14041
14080
|
var DEFAULT_SOCKET_PATH = "/socket.io";
|
|
14042
14081
|
/**
|
|
14043
|
-
* The `ChatTurn.id` of the handoff transcript event.
|
|
14044
|
-
*
|
|
14045
|
-
*
|
|
14046
|
-
*
|
|
14082
|
+
* The `ChatTurn.id` of the FIRST handoff transcript event. Prefixed so it can
|
|
14083
|
+
* never be mistaken for — or collide with — a server-minted turn id in the
|
|
14084
|
+
* id-keyed `setTurns` passes `send`/`streamReply` run. A conversation handed
|
|
14085
|
+
* back and taken over again gets a second marker, suffixed `-2`, `-3`, … (see
|
|
14086
|
+
* `markHandoffToHuman`); the first keeps the bare literal it always had.
|
|
14047
14087
|
*/
|
|
14048
14088
|
var HANDOFF_EVENT_TURN_ID = "event-handoff";
|
|
14089
|
+
/** Prefix of a hand-back transcript event's id, suffixed with its ordinal — see `markHandbackToAi`. */
|
|
14090
|
+
var HANDBACK_EVENT_TURN_ID = "event-handback";
|
|
14049
14091
|
/** Must equal `WIDGET_DESK_MESSAGE_EVENT` in `apps/api/src/realtime/widget-room.ts`. */
|
|
14050
14092
|
var DESK_MESSAGE_EVENT = "desk:message";
|
|
14051
14093
|
/** Must equal `WIDGET_DESK_TYPING_EVENT` in `apps/api/src/realtime/widget-room.ts`. */
|
|
@@ -14230,7 +14272,7 @@ function stripCartLineIds(cart) {
|
|
|
14230
14272
|
};
|
|
14231
14273
|
}
|
|
14232
14274
|
function useChatSession(options) {
|
|
14233
|
-
const { embedKey, attribution, apiBase = DEFAULT_API_BASE, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS, idlePollIntervalMs = DEFAULT_IDLE_POLL_INTERVAL_MS, socketUrl, socketPath = DEFAULT_SOCKET_PATH, collector, hostRoutes } = options;
|
|
14275
|
+
const { embedKey, attribution, apiBase = DEFAULT_API_BASE, pollIntervalMs = DEFAULT_POLL_INTERVAL_MS, idlePollIntervalMs = DEFAULT_IDLE_POLL_INTERVAL_MS, lightPollIntervalMs = DEFAULT_LIGHT_POLL_INTERVAL_MS, socketUrl, socketPath = DEFAULT_SOCKET_PATH, collector, hostRoutes } = options;
|
|
14234
14276
|
const fetchImpl = options.fetchImpl ?? fetch;
|
|
14235
14277
|
const socketFactory = options.socketImpl;
|
|
14236
14278
|
const now = useMemo(() => options.now ?? (() => Date.now()), []);
|
|
@@ -14334,6 +14376,19 @@ function useChatSession(options) {
|
|
|
14334
14376
|
const lastSeqRef = useRef(0);
|
|
14335
14377
|
/** Every `seq` already rendered, from EITHER path — the actual dedupe guard; see the module doc comment. */
|
|
14336
14378
|
const seenSeqRef = useRef(/* @__PURE__ */ new Set());
|
|
14379
|
+
/**
|
|
14380
|
+
* Seqs a poll page skipped over (seq 7 arrived, seq 6 did not), with the
|
|
14381
|
+
* instant each was first missed. The poll keeps asking from below the
|
|
14382
|
+
* oldest one for `SEQ_GAP_HOLD_MS` — see that constant.
|
|
14383
|
+
*/
|
|
14384
|
+
const seqGapsRef = useRef(/* @__PURE__ */ new Map());
|
|
14385
|
+
/**
|
|
14386
|
+
* The ids of the exchange whose `POST /widget/chat` reply is streaming, or
|
|
14387
|
+
* `null` — so a hand-back that lands mid-reply keeps `status` at
|
|
14388
|
+
* `'streaming'` and puts its divider above that exchange (SAA-420). See
|
|
14389
|
+
* `markHandbackToAi`.
|
|
14390
|
+
*/
|
|
14391
|
+
const replyInFlightRef = useRef(null);
|
|
14337
14392
|
const pollTimerRef = useRef(void 0);
|
|
14338
14393
|
const pollIntervalRef = useRef(pollIntervalMs);
|
|
14339
14394
|
const mountedRef = useRef(true);
|
|
@@ -14422,6 +14477,13 @@ function useChatSession(options) {
|
|
|
14422
14477
|
*/
|
|
14423
14478
|
const handoffEventAppendedRef = useRef(false);
|
|
14424
14479
|
/**
|
|
14480
|
+
* How many handoff / hand-back markers this page load has appended — the
|
|
14481
|
+
* ordinals that keep each marker's id unique when a conversation goes to a
|
|
14482
|
+
* person, comes back, and goes again (see `markHandbackToAi`).
|
|
14483
|
+
*/
|
|
14484
|
+
const handoffCountRef = useRef(0);
|
|
14485
|
+
const handbackCountRef = useRef(0);
|
|
14486
|
+
/**
|
|
14425
14487
|
* The CURRENT chat token's expiry, epoch ms — `Date.parse` of whatever
|
|
14426
14488
|
* `expiresAt` the last successful boot or refresh returned, `null` before
|
|
14427
14489
|
* the first one (or when an api build predates the field, in which case
|
|
@@ -14492,8 +14554,10 @@ function useChatSession(options) {
|
|
|
14492
14554
|
/**
|
|
14493
14555
|
* The ONE place turns from push OR poll become `ChatTurn`s. Dedupes by
|
|
14494
14556
|
* `seq` (never renders the same turn twice, whichever path delivers it
|
|
14495
|
-
* first)
|
|
14496
|
-
*
|
|
14557
|
+
* first). Only a `'poll'` batch advances `lastSeqRef` (the poll's
|
|
14558
|
+
* `afterSeq` query param) — see the module doc comment's "Only a POLL
|
|
14559
|
+
* result moves the poll cursor" for the reply that was lost when a push
|
|
14560
|
+
* moved it too.
|
|
14497
14561
|
*
|
|
14498
14562
|
* ## A seen seq is still allowed to CORRECT the turn it named
|
|
14499
14563
|
*
|
|
@@ -14520,15 +14584,24 @@ function useChatSession(options) {
|
|
|
14520
14584
|
* is no case where it should, since the restrictive answer is the
|
|
14521
14585
|
* socket's and the socket arrives first.
|
|
14522
14586
|
*/
|
|
14523
|
-
const mergeIncoming = useCallback((incoming) => {
|
|
14587
|
+
const mergeIncoming = useCallback((incoming, source) => {
|
|
14524
14588
|
if (!mountedRef.current || !Array.isArray(incoming) || incoming.length === 0) return;
|
|
14525
14589
|
const sorted = incoming.slice().sort((a, b) => a.seq - b.seq);
|
|
14590
|
+
if (source === "poll") {
|
|
14591
|
+
const returned = new Set(sorted.map((t) => t.seq));
|
|
14592
|
+
const top = sorted.reduce((max, t) => Math.max(max, t.seq), lastSeqRef.current);
|
|
14593
|
+
const now = Date.now();
|
|
14594
|
+
if (lastSeqRef.current > 0) {
|
|
14595
|
+
for (let seq = Math.max(lastSeqRef.current + 1, top - 20); seq < top; seq++) if (!returned.has(seq) && !seenSeqRef.current.has(seq)) seqGapsRef.current.set(seq, now);
|
|
14596
|
+
}
|
|
14597
|
+
for (const seq of returned) seqGapsRef.current.delete(seq);
|
|
14598
|
+
lastSeqRef.current = top;
|
|
14599
|
+
}
|
|
14526
14600
|
const fresh = sorted.filter((t) => !seenSeqRef.current.has(t.seq));
|
|
14527
14601
|
const repeats = sorted.filter((t) => seenSeqRef.current.has(t.seq));
|
|
14528
14602
|
if (fresh.length === 0 && repeats.length === 0) return;
|
|
14529
14603
|
if (fresh.some((t) => speakerFor(t.role) === "agent")) clearDeskTyping();
|
|
14530
14604
|
for (const t of fresh) seenSeqRef.current.add(t.seq);
|
|
14531
|
-
lastSeqRef.current = fresh.reduce((max, t) => Math.max(max, t.seq), lastSeqRef.current);
|
|
14532
14605
|
setTurns((prev) => {
|
|
14533
14606
|
const baseId = (id) => {
|
|
14534
14607
|
const colon = id.indexOf(":");
|
|
@@ -14594,30 +14667,107 @@ function useChatSession(options) {
|
|
|
14594
14667
|
setStatus("escalated");
|
|
14595
14668
|
if (handoffEventAppendedRef.current) return;
|
|
14596
14669
|
handoffEventAppendedRef.current = true;
|
|
14670
|
+
handoffCountRef.current += 1;
|
|
14671
|
+
const id = handoffCountRef.current === 1 ? HANDOFF_EVENT_TURN_ID : `${HANDOFF_EVENT_TURN_ID}-${handoffCountRef.current}`;
|
|
14597
14672
|
setTurns((prev) => [...prev, {
|
|
14598
|
-
id
|
|
14673
|
+
id,
|
|
14599
14674
|
speaker: "event",
|
|
14600
14675
|
event: "handoff",
|
|
14601
14676
|
text: "",
|
|
14602
14677
|
final: true
|
|
14603
14678
|
}]);
|
|
14604
14679
|
}, []);
|
|
14605
|
-
|
|
14680
|
+
/**
|
|
14681
|
+
* The desk handed the conversation back to the concierge (SAA-420): leave
|
|
14682
|
+
* the escalated state and record the hand-back IN the transcript, the
|
|
14683
|
+
* mirror of {@link markHandoffToHuman}.
|
|
14684
|
+
*
|
|
14685
|
+
* Two transports report it — the widget room's `desk:ownership { to: 'ai' }`
|
|
14686
|
+
* push, and the SSE `resumed` event the AI's first reply after a release
|
|
14687
|
+
* carries for a visitor whose socket missed the push. Either may arrive
|
|
14688
|
+
* first, or both; the first one does the work and the second finds nothing
|
|
14689
|
+
* to undo.
|
|
14690
|
+
*
|
|
14691
|
+
* A no-op unless this page load has a handoff on screen. `resumed` is
|
|
14692
|
+
* computed server-side from the conversation's ownership history, which
|
|
14693
|
+
* can name a release this page never saw the escalation for (yesterday's
|
|
14694
|
+
* session, say); a "back with the concierge" divider with no handoff above
|
|
14695
|
+
* it would announce a return from somewhere the shopper never went.
|
|
14696
|
+
*
|
|
14697
|
+
* Resets the once-per-handoff guard, so a SECOND takeover draws its own
|
|
14698
|
+
* handoff marker rather than being swallowed by the first one's. Stops the
|
|
14699
|
+
* poll interval and (via `status` leaving `'escalated'`) closes the socket
|
|
14700
|
+
* — both exist only for a person-held conversation — and drops the
|
|
14701
|
+
* operator's typing dots, which nothing will now retire.
|
|
14702
|
+
*
|
|
14703
|
+
* @param options.before ids of turns the divider must sit ABOVE. The
|
|
14704
|
+
* `resumed` path passes the exchange it arrived on: the release
|
|
14705
|
+
* happened before the shopper's message, so the divider goes there
|
|
14706
|
+
* rather than under the reply it interrupts.
|
|
14707
|
+
* @param options.next the status to land on — `'streaming'` while a reply
|
|
14708
|
+
* is still arriving on the same stream, `'idle'` otherwise.
|
|
14709
|
+
*/
|
|
14710
|
+
const markHandbackToAi = useCallback((options) => {
|
|
14711
|
+
if (!mountedRef.current || !handoffEventAppendedRef.current) return;
|
|
14712
|
+
handoffEventAppendedRef.current = false;
|
|
14713
|
+
handbackCountRef.current += 1;
|
|
14714
|
+
const marker = {
|
|
14715
|
+
id: `${HANDBACK_EVENT_TURN_ID}-${handbackCountRef.current}`,
|
|
14716
|
+
speaker: "event",
|
|
14717
|
+
event: "handback",
|
|
14718
|
+
text: "",
|
|
14719
|
+
final: true
|
|
14720
|
+
};
|
|
14721
|
+
const before = new Set(options?.before ?? replyInFlightRef.current ?? []);
|
|
14722
|
+
setTurns((prev) => {
|
|
14723
|
+
const at = prev.findIndex((t) => before.has(t.id));
|
|
14724
|
+
return at === -1 ? [...prev, marker] : [
|
|
14725
|
+
...prev.slice(0, at),
|
|
14726
|
+
marker,
|
|
14727
|
+
...prev.slice(at)
|
|
14728
|
+
];
|
|
14729
|
+
});
|
|
14730
|
+
const next = options?.next ?? (replyInFlightRef.current !== null ? "streaming" : "idle");
|
|
14731
|
+
setStatus((prev) => prev === "escalated" ? next : prev);
|
|
14732
|
+
if (pollTimerRef.current !== void 0) {
|
|
14733
|
+
clearInterval(pollTimerRef.current);
|
|
14734
|
+
pollTimerRef.current = void 0;
|
|
14735
|
+
}
|
|
14736
|
+
clearDeskTyping();
|
|
14737
|
+
}, [clearDeskTyping]);
|
|
14738
|
+
const poll = useCallback(async (detectHandoff) => {
|
|
14606
14739
|
const chatToken = chatTokenRef.current;
|
|
14607
14740
|
if (chatToken === void 0) return;
|
|
14741
|
+
let afterSeq = lastSeqRef.current;
|
|
14742
|
+
const now = Date.now();
|
|
14743
|
+
for (const [seq, missedAt] of seqGapsRef.current) if (seenSeqRef.current.has(seq) || now - missedAt > SEQ_GAP_HOLD_MS) seqGapsRef.current.delete(seq);
|
|
14744
|
+
else afterSeq = Math.min(afterSeq, seq - 1);
|
|
14608
14745
|
try {
|
|
14609
|
-
const res = await fetchImpl(withEmbedKeyParam(`${apiBase}/messages?afterSeq=${
|
|
14746
|
+
const res = await fetchImpl(withEmbedKeyParam(`${apiBase}/messages?afterSeq=${afterSeq}`, embedKey), { headers: { authorization: `Bearer ${chatToken}` } });
|
|
14610
14747
|
if (!res.ok) return;
|
|
14611
14748
|
const body = await res.json();
|
|
14612
|
-
|
|
14749
|
+
const rows = body.messages ?? body.turns ?? [];
|
|
14750
|
+
if (detectHandoff && Array.isArray(rows) && rows.some((t) => t.role === "human" && !seenSeqRef.current.has(t.seq))) markHandoffToHuman();
|
|
14751
|
+
mergeIncoming(rows, "poll");
|
|
14613
14752
|
} catch {}
|
|
14614
14753
|
}, [
|
|
14615
14754
|
apiBase,
|
|
14616
14755
|
embedKey,
|
|
14617
14756
|
fetchImpl,
|
|
14618
|
-
mergeIncoming
|
|
14757
|
+
mergeIncoming,
|
|
14758
|
+
markHandoffToHuman
|
|
14619
14759
|
]);
|
|
14620
14760
|
/**
|
|
14761
|
+
* The CURRENT `poll`, for the socket's `connect` handler. A ref rather than
|
|
14762
|
+
* a dependency of the socket effect: that effect tears the socket down and
|
|
14763
|
+
* opens a new one whenever a dependency changes, and a catch-up poll is not
|
|
14764
|
+
* a reason to drop a live connection.
|
|
14765
|
+
*/
|
|
14766
|
+
const pollRef = useRef(poll);
|
|
14767
|
+
useEffect(() => {
|
|
14768
|
+
pollRef.current = poll;
|
|
14769
|
+
}, [poll]);
|
|
14770
|
+
/**
|
|
14621
14771
|
* (Re)starts the interval at `intervalMs` — called both on first
|
|
14622
14772
|
* escalation and whenever `connection` flips (see the effect below), so
|
|
14623
14773
|
* the cadence always reflects the CURRENT socket state, not just the one
|
|
@@ -14733,7 +14883,8 @@ function useChatSession(options) {
|
|
|
14733
14883
|
const bootSession = useCallback(async (args) => {
|
|
14734
14884
|
const isStale = args.isStale;
|
|
14735
14885
|
const isMount = args.phase === "mount";
|
|
14736
|
-
const
|
|
14886
|
+
const own = readStoredVisitor();
|
|
14887
|
+
const stored = !own.visitorId && collector?.visitorIdentity || own;
|
|
14737
14888
|
const bootRequestedAt = now();
|
|
14738
14889
|
const res = await fetchImpl(withEmbedKeyParam(`${apiBase}/session`, embedKey), {
|
|
14739
14890
|
method: "POST",
|
|
@@ -14754,6 +14905,7 @@ function useChatSession(options) {
|
|
|
14754
14905
|
const ttlMs = tokenTtlMs(res, body.expiresAt, receivedAt);
|
|
14755
14906
|
adoptChatToken(body.chatToken);
|
|
14756
14907
|
lastSeqRef.current = 0;
|
|
14908
|
+
seqGapsRef.current.clear();
|
|
14757
14909
|
seenSeqRef.current.clear();
|
|
14758
14910
|
visitorSessionIdRef.current = body.visitorSessionId;
|
|
14759
14911
|
sessionOriginRef.current = bootRequestedAt;
|
|
@@ -14826,6 +14978,7 @@ function useChatSession(options) {
|
|
|
14826
14978
|
}]);
|
|
14827
14979
|
if (isMount && body.resumed === true) {
|
|
14828
14980
|
lastSeqRef.current = 0;
|
|
14981
|
+
seqGapsRef.current.clear();
|
|
14829
14982
|
poll();
|
|
14830
14983
|
}
|
|
14831
14984
|
setStatus((prev) => prev === "escalated" ? prev : "idle");
|
|
@@ -15050,7 +15203,7 @@ function useChatSession(options) {
|
|
|
15050
15203
|
let cancelled = false;
|
|
15051
15204
|
setConnection("connecting");
|
|
15052
15205
|
(async () => {
|
|
15053
|
-
const factory = socketFactory ?? (await import("./esm-
|
|
15206
|
+
const factory = socketFactory ?? (await import("./esm-D2iq2DjO.js")).io;
|
|
15054
15207
|
if (cancelled) return;
|
|
15055
15208
|
const socket = factory(`${socketUrl}${SOCKET_NAMESPACE}`, {
|
|
15056
15209
|
path: socketPath,
|
|
@@ -15061,7 +15214,9 @@ function useChatSession(options) {
|
|
|
15061
15214
|
});
|
|
15062
15215
|
socketRef.current = socket;
|
|
15063
15216
|
socket.on("connect", () => {
|
|
15064
|
-
if (mountedRef.current)
|
|
15217
|
+
if (!mountedRef.current) return;
|
|
15218
|
+
setConnection("connected");
|
|
15219
|
+
pollRef.current();
|
|
15065
15220
|
});
|
|
15066
15221
|
socket.on("disconnect", () => {
|
|
15067
15222
|
if (mountedRef.current) setConnection("disconnected");
|
|
@@ -15070,7 +15225,13 @@ function useChatSession(options) {
|
|
|
15070
15225
|
if (mountedRef.current) setConnection("disconnected");
|
|
15071
15226
|
});
|
|
15072
15227
|
socket.on(DESK_MESSAGE_EVENT, (message) => {
|
|
15073
|
-
mergeIncoming([message]);
|
|
15228
|
+
mergeIncoming([message], "push");
|
|
15229
|
+
});
|
|
15230
|
+
socket.on(DESK_OWNERSHIP_EVENT, (payload) => {
|
|
15231
|
+
const event = parseDeskOwnershipEvent(payload);
|
|
15232
|
+
if (!event || !mountedRef.current) return;
|
|
15233
|
+
if (event.to === "ai") markHandbackToAi();
|
|
15234
|
+
else markHandoffToHuman();
|
|
15074
15235
|
});
|
|
15075
15236
|
socket.on(DESK_TYPING_EVENT, () => {
|
|
15076
15237
|
if (!mountedRef.current) return;
|
|
@@ -15093,6 +15254,8 @@ function useChatSession(options) {
|
|
|
15093
15254
|
socketFactory,
|
|
15094
15255
|
mergeIncoming,
|
|
15095
15256
|
clearDeskTyping,
|
|
15257
|
+
markHandbackToAi,
|
|
15258
|
+
markHandoffToHuman,
|
|
15096
15259
|
bootGeneration
|
|
15097
15260
|
]);
|
|
15098
15261
|
useEffect(() => {
|
|
@@ -15105,6 +15268,33 @@ function useChatSession(options) {
|
|
|
15105
15268
|
pollIntervalMs,
|
|
15106
15269
|
idlePollIntervalMs
|
|
15107
15270
|
]);
|
|
15271
|
+
useEffect(() => {
|
|
15272
|
+
if (status !== "escalated") return;
|
|
15273
|
+
pollRef.current();
|
|
15274
|
+
}, [status]);
|
|
15275
|
+
const escalated = status === "escalated";
|
|
15276
|
+
useEffect(() => {
|
|
15277
|
+
if (!ready || escalated) return;
|
|
15278
|
+
let timer;
|
|
15279
|
+
const sync = () => {
|
|
15280
|
+
if (document.visibilityState === "hidden") {
|
|
15281
|
+
clearInterval(timer);
|
|
15282
|
+
timer = void 0;
|
|
15283
|
+
} else if (timer === void 0) timer = setInterval(() => {
|
|
15284
|
+
if (replyInFlightRef.current === null) pollRef.current(true);
|
|
15285
|
+
}, lightPollIntervalMs);
|
|
15286
|
+
};
|
|
15287
|
+
sync();
|
|
15288
|
+
document.addEventListener("visibilitychange", sync);
|
|
15289
|
+
return () => {
|
|
15290
|
+
clearInterval(timer);
|
|
15291
|
+
document.removeEventListener("visibilitychange", sync);
|
|
15292
|
+
};
|
|
15293
|
+
}, [
|
|
15294
|
+
ready,
|
|
15295
|
+
escalated,
|
|
15296
|
+
lightPollIntervalMs
|
|
15297
|
+
]);
|
|
15108
15298
|
/**
|
|
15109
15299
|
* The ONE place a turn is posted to `POST /widget/chat`, shared by `send`
|
|
15110
15300
|
* (shopper text) and `sendReport` (a typed storefront report).
|
|
@@ -15140,7 +15330,9 @@ function useChatSession(options) {
|
|
|
15140
15330
|
}
|
|
15141
15331
|
]);
|
|
15142
15332
|
setStatus((prev) => prev === "escalated" ? prev : "streaming");
|
|
15333
|
+
replyInFlightRef.current = [callerTurnId, agentTurnId];
|
|
15143
15334
|
const rollBack = () => {
|
|
15335
|
+
replyInFlightRef.current = null;
|
|
15144
15336
|
setTurns((prev) => prev.filter((t) => t.id !== callerTurnId && t.id !== agentTurnId));
|
|
15145
15337
|
};
|
|
15146
15338
|
const postChat = (cart) => fetchImpl(withEmbedKeyParam(`${apiBase}/chat`, embedKey), {
|
|
@@ -15202,7 +15394,14 @@ function useChatSession(options) {
|
|
|
15202
15394
|
onEscalated: () => {
|
|
15203
15395
|
markHandoffToHuman();
|
|
15204
15396
|
},
|
|
15397
|
+
onResumed: () => {
|
|
15398
|
+
markHandbackToAi({
|
|
15399
|
+
before: [callerTurnId, agentTurnId],
|
|
15400
|
+
next: "streaming"
|
|
15401
|
+
});
|
|
15402
|
+
},
|
|
15205
15403
|
onDone: (turnId) => {
|
|
15404
|
+
replyInFlightRef.current = null;
|
|
15206
15405
|
if (!mountedRef.current) return;
|
|
15207
15406
|
setTurns((prev) => prev.filter((t) => t.id !== turnId || t.id === agentTurnId).map((t) => t.id === agentTurnId ? {
|
|
15208
15407
|
...t,
|
|
@@ -15212,6 +15411,7 @@ function useChatSession(options) {
|
|
|
15212
15411
|
setStatus((prev) => prev === "escalated" ? prev : "idle");
|
|
15213
15412
|
},
|
|
15214
15413
|
onError: (message) => {
|
|
15414
|
+
replyInFlightRef.current = null;
|
|
15215
15415
|
if (!mountedRef.current) return;
|
|
15216
15416
|
setTurns((prev) => prev.map((t) => t.id === agentTurnId ? {
|
|
15217
15417
|
...t,
|
|
@@ -15221,6 +15421,8 @@ function useChatSession(options) {
|
|
|
15221
15421
|
setError(message);
|
|
15222
15422
|
},
|
|
15223
15423
|
isMounted: () => mountedRef.current
|
|
15424
|
+
}).finally(() => {
|
|
15425
|
+
replyInFlightRef.current = null;
|
|
15224
15426
|
});
|
|
15225
15427
|
return true;
|
|
15226
15428
|
}, [
|
|
@@ -15228,7 +15430,8 @@ function useChatSession(options) {
|
|
|
15228
15430
|
embedKey,
|
|
15229
15431
|
fetchImpl,
|
|
15230
15432
|
status,
|
|
15231
|
-
markHandoffToHuman
|
|
15433
|
+
markHandoffToHuman,
|
|
15434
|
+
markHandbackToAi
|
|
15232
15435
|
]);
|
|
15233
15436
|
const send = useCallback(async (text, options) => postTurn({ message: text }, options), [postTurn]);
|
|
15234
15437
|
const sendReport = useCallback(async (report, options) => postTurn({ report }, options?.quietOnHttpError === true ? { quietOnHttpError: true } : void 0), [postTurn]);
|
|
@@ -15645,7 +15848,7 @@ function useChatSession(options) {
|
|
|
15645
15848
|
* promise and is trivially unit-testable with a synthetic `ReadableStream`.
|
|
15646
15849
|
*/
|
|
15647
15850
|
async function streamReply(args) {
|
|
15648
|
-
const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onDone, onError, isMounted } = args;
|
|
15851
|
+
const { body, agentTurnId, setTurns, onCardsEvent, onCheckoutEvent, onCartAddEvent, onActEvent, onEscalated, onResumed, onDone, onError, isMounted } = args;
|
|
15649
15852
|
const reader = body.getReader();
|
|
15650
15853
|
const decoder = new TextDecoder();
|
|
15651
15854
|
const parser = new SseFrameParser();
|
|
@@ -15788,6 +15991,9 @@ async function streamReply(args) {
|
|
|
15788
15991
|
case "escalated":
|
|
15789
15992
|
onEscalated();
|
|
15790
15993
|
break;
|
|
15994
|
+
case "resumed":
|
|
15995
|
+
onResumed();
|
|
15996
|
+
break;
|
|
15791
15997
|
case "done":
|
|
15792
15998
|
onDone(evt.data?.turnId ?? agentTurnId);
|
|
15793
15999
|
break;
|
|
@@ -15810,7 +16016,7 @@ async function streamReply(args) {
|
|
|
15810
16016
|
* cache makes a second `start()` after `stop()` free).
|
|
15811
16017
|
*/
|
|
15812
16018
|
async function loadVoiceProtocol() {
|
|
15813
|
-
const [telemetry, chat] = await Promise.all([import("./telemetry-
|
|
16019
|
+
const [telemetry, chat] = await Promise.all([import("./telemetry-UHSrhVyf.js"), import("./chat-CrbRIHVN.js")]);
|
|
15814
16020
|
return {
|
|
15815
16021
|
decodeTelemetry: telemetry.decodeTelemetry,
|
|
15816
16022
|
encodeCallerText: telemetry.encodeCallerText,
|
|
@@ -17649,7 +17855,7 @@ function ConciergeWidget({ renderer, ...props }) {
|
|
|
17649
17855
|
renderer: renderer ?? rendererFor(props.generation)
|
|
17650
17856
|
});
|
|
17651
17857
|
}
|
|
17652
|
-
function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bridge, siteProfile, collector, messages = defaultWidgetMessages, locale = "en", productHref, hostRoutes, curationHref, brandPrimary, brandSecondary, brandAccent, avatar, attribution, privacyChoices, color, type, identity, layout, copy, bottomOffset, showPrice, cardImageAspect, voiceAvailable, direction, proactive, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, cartLineIds }) {
|
|
17858
|
+
function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bridge, siteProfile, collector, messages = defaultWidgetMessages, locale = "en", productHref, hostRoutes, curationHref, brandPrimary, brandSecondary, brandAccent, avatar, attribution, privacyChoices, color, type, identity, layout, copy, bottomOffset, showPrice, cardImageAspect, starters, voiceAvailable, direction, proactive, initialDraft, initialSelection, initialFocus, initialMinimised, insets, hold, audio, onReady, cartLineIds }) {
|
|
17653
17859
|
/**
|
|
17654
17860
|
* Maps the tenant's semantic config fields onto the widget's historical
|
|
17655
17861
|
* CSS custom properties — this is the "one becomes the other" site
|
|
@@ -19362,6 +19568,11 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19362
19568
|
};
|
|
19363
19569
|
return bridge.onPageChange(read);
|
|
19364
19570
|
}, [bridge]);
|
|
19571
|
+
const [pick, setPick] = useState();
|
|
19572
|
+
useEffect(() => {
|
|
19573
|
+
if (starters) import("./starters-pick-noq7o_W8.js").then((mod) => setPick(() => mod.startersFor), () => {});
|
|
19574
|
+
}, [starters]);
|
|
19575
|
+
const suggestions = pick ? pick(starters, location.pathname, locale) : starters ? [] : void 0;
|
|
19365
19576
|
/**
|
|
19366
19577
|
* The shelf (§3.4): the LATEST curation, and only the latest.
|
|
19367
19578
|
*
|
|
@@ -19439,6 +19650,7 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19439
19650
|
...productHref ? { productHref } : {},
|
|
19440
19651
|
...navigate ? { navigate } : {},
|
|
19441
19652
|
messages,
|
|
19653
|
+
suggestions,
|
|
19442
19654
|
locale,
|
|
19443
19655
|
...skinStyle !== void 0 ? { skinStyle } : {},
|
|
19444
19656
|
...avatar !== void 0 ? { avatar } : {},
|
|
@@ -19449,4 +19661,4 @@ function ConciergeHost({ renderer, embedKey, apiBase, socketUrl, socketPath, bri
|
|
|
19449
19661
|
});
|
|
19450
19662
|
}
|
|
19451
19663
|
//#endregion
|
|
19452
|
-
export { deriveDockState as $,
|
|
19664
|
+
export { deriveDockState as $, themeToCss as $t, rendererFor as A, cn as An, SHEET_PEEK_MAX as At, nearestPosition as B, pillAnchor as Bt, readsAsCartViewIntent as C, DEFAULT_WIDGET_AVATAR as Cn, PILL_MARK as Ct, WidgetCardList as D, RopeKnot as Dn, SHEET_EXPANDED_DESKTOP_MAX as Dt, WidgetCartSummary as E, KNOT_PATH as En, ROW_H as Et, ConciergeLauncher as F, bottomLen as Ft, botStateFor as G, sheetMaxHeightLen as Gt, positionClasses as H, readStoredAlign as Ht, CONCIERGE_POSITIONS as I, containerAnchor as It, SessionLog as J, CARD_RADIUS_MAX_PX as Jt, SseFrameParser as K, snapAlign as Kt, DEFAULT_CONCIERGE_POSITION as L, geometryVars as Lt, ShellRenderer as M, SHEET_TUCK as Mt, deriveWidgetView as N, SHORT_VIEWPORT as Nt, WidgetMarkdown as O, BotFace as On, SHEET_EXPANDED_VH as Ot, ConciergeShell as P, Z_INDEX as Pt, DOCK_STATES as Q, deriveTheme as Qt, alignOf as R, persistAlign as Rt, basketIntentFromTurns as S, MorphingLoader as Sn, PILL_H as St, textDirectionFor as T, isWidgetAvatar as Tn, RADII as Tt, positionForArrow as U, readStoredMinimised as Ut, panelClasses as V, readStored as Vt, IDLE_SNAPSHOT as W, rowWidthLen as Wt, latencyBetween as X, SYSTEM_FONT_STACK as Xt, formatMs as Y, SHEET_RADIUS_MAX_PX as Yt, Dock as Z, WIDGET_THEME_TOKENS as Zt, isSameOriginPath as _, withAlpha as _n, FLOAT_DUCK_DISMISS_MS as _t, MAX_REPORTED_CART_LINES as a, linearRgbToOklab as an, formatMoney as at, VoiceWidget as b, resolveWidgetMessages as bn, MARK as bt, deriveCallPhase as c, oklabToHex as cn, CONTROL as ct, resolveCheckoutUrl as d, oklchToHex as dn, DESKTOP_GUTTER as dt, themeToInlineStyle as en, deriveDockView as et, toChatCart as f, oklchToOklab as fn, DESKTOP_WIDTHS as ft, CHECKOUT_CAPTURE_REQUIRED as g, srgbToLinear as gn, DRAG_TAP_SLOP_PX as gt, useVoiceSession as h, rotateHue as hn, DRAG_CLICK_WINDOW_MS as ht, ConciergeWidget as i, hexToOklch as in, idleConciergeInput as it, DockRenderer as j, SHEET_TOP_CLEARANCE as jt, parseBlocks as k, labelProps as kn, SHEET_GAP as kt, mergeAddedCartLine as l, oklabToLinearRgb as ln, DESKTOP_BOTTOM as lt, createWidgetVoiceTokenFetcher as m, relativeLuminance as mn, DOCK_MINIMISED_STORAGE_KEY as mt, CART_LINE_VARIANT_ID_SHAPE as n, formatHex as nn, CONCIERGE_STATES as nt, cartLinesFromSnapshot as o, linearToSrgb as on, ACTIVITY_W as ot, ROOM_EVENTS as p, parseHex as pn, DOCK_ALIGN_STORAGE_KEY as pt, SESSION_EVENTS as q, writeStored as qt, ConciergeHost as r, hexToOklab as rn, deriveConciergeState as rt, chooseOptionsAction as s, mixToward as sn, BOTTOM_FLOOR as st, CART_LINE_PLATFORM_VARIANT_ID_SHAPE as t, contrastRatio as tn, idleDockInput as tt, resolveAddToCartHandler as u, oklabToOklch as un, DESKTOP_BREAKPOINT as ut, useChatSession as v, defaultWidgetMessages as vn, FLOAT_GAP as vt, readsAsCheckoutIntent as w, WIDGET_AVATARS as wn, PROACTIVE_NUDGE_MS as wt, VoiceWidgetWithRenderer as x, widgetMessagesFromCopy as xn, MOBILE_MARGIN as xt, detectPage as y, formatMessage as yn, GLASS_IDLE_MS as yt, edgeOf as z, persistMinimised as zt };
|