@uptrademedia/site-kit 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/dist/analytics/index.d.mts +2 -2
  2. package/dist/analytics/index.d.ts +2 -2
  3. package/dist/analytics/index.js +6 -6
  4. package/dist/analytics/index.mjs +2 -2
  5. package/dist/{api-l44k92vp.d.mts → api-CWtoFJCO.d.mts} +1 -1
  6. package/dist/{api-l44k92vp.d.ts → api-CWtoFJCO.d.ts} +1 -1
  7. package/dist/blog/index.d.mts +2 -2
  8. package/dist/blog/index.d.ts +2 -2
  9. package/dist/blog/server.d.mts +1 -1
  10. package/dist/blog/server.d.ts +1 -1
  11. package/dist/{chunk-HEUULOSC.js → chunk-2MNLOYDD.js} +3 -3
  12. package/dist/{chunk-HEUULOSC.js.map → chunk-2MNLOYDD.js.map} +1 -1
  13. package/dist/{chunk-3LOFIO77.mjs → chunk-44OMJFCG.mjs} +187 -193
  14. package/dist/chunk-44OMJFCG.mjs.map +1 -0
  15. package/dist/{chunk-C5TQLU5U.js → chunk-6LBLKQ5Q.js} +132 -85
  16. package/dist/chunk-6LBLKQ5Q.js.map +1 -0
  17. package/dist/{chunk-VFJ3NNCY.js → chunk-DERI27QC.js} +187 -193
  18. package/dist/chunk-DERI27QC.js.map +1 -0
  19. package/dist/{chunk-HGTTGJVZ.js → chunk-LBHEVL6U.js} +3 -3
  20. package/dist/{chunk-HGTTGJVZ.js.map → chunk-LBHEVL6U.js.map} +1 -1
  21. package/dist/{chunk-YT5SBY5W.mjs → chunk-MLJXNFUO.mjs} +3 -3
  22. package/dist/{chunk-YT5SBY5W.mjs.map → chunk-MLJXNFUO.mjs.map} +1 -1
  23. package/dist/{chunk-OW2C3ATV.mjs → chunk-R6V7DQ24.mjs} +3 -3
  24. package/dist/{chunk-OW2C3ATV.mjs.map → chunk-R6V7DQ24.mjs.map} +1 -1
  25. package/dist/{chunk-RLO3QJ65.mjs → chunk-TJBXNQ2W.mjs} +131 -85
  26. package/dist/chunk-TJBXNQ2W.mjs.map +1 -0
  27. package/dist/cli/index.js +706 -706
  28. package/dist/cli/index.js.map +1 -1
  29. package/dist/cli/index.mjs +700 -700
  30. package/dist/cli/index.mjs.map +1 -1
  31. package/dist/commerce/index.d.mts +3 -3
  32. package/dist/commerce/index.d.ts +3 -3
  33. package/dist/commerce/server.d.mts +1 -1
  34. package/dist/commerce/server.d.ts +1 -1
  35. package/dist/engage/index.d.mts +2 -2
  36. package/dist/engage/index.d.ts +2 -2
  37. package/dist/engage/index.js +4 -4
  38. package/dist/engage/index.mjs +1 -1
  39. package/dist/images/index.d.mts +1 -1
  40. package/dist/images/index.d.ts +1 -1
  41. package/dist/index.d.mts +7 -7
  42. package/dist/index.d.ts +7 -7
  43. package/dist/index.js +4 -4
  44. package/dist/index.mjs +2 -2
  45. package/dist/llms/index.d.mts +2 -2
  46. package/dist/llms/index.d.ts +2 -2
  47. package/dist/{routing-D311WhuV.d.ts → routing-BI69sU8F.d.ts} +1 -1
  48. package/dist/{routing-bTjqOM8S.d.mts → routing-Bg1nr9N0.d.mts} +1 -1
  49. package/dist/{scanner-VNEXRTZF.mjs → scanner-7ZMUM2P5.mjs} +3 -3
  50. package/dist/{scanner-VNEXRTZF.mjs.map → scanner-7ZMUM2P5.mjs.map} +1 -1
  51. package/dist/{scanner-CVKYTPUO.js → scanner-OY7UF3WA.js} +14 -14
  52. package/dist/{scanner-CVKYTPUO.js.map → scanner-OY7UF3WA.js.map} +1 -1
  53. package/dist/seo/index.d.mts +3 -3
  54. package/dist/seo/index.d.ts +3 -3
  55. package/dist/seo/server.d.mts +2 -2
  56. package/dist/seo/server.d.ts +2 -2
  57. package/dist/setup/index.js +2 -2
  58. package/dist/setup/index.mjs +1 -1
  59. package/dist/setup/server.js +2 -2
  60. package/dist/setup/server.mjs +1 -1
  61. package/dist/sitemap/index.d.mts +1 -1
  62. package/dist/sitemap/index.d.ts +1 -1
  63. package/dist/{socket-loader-3FWQWPDQ.js → socket-loader-J26QHHOB.js} +2 -2
  64. package/dist/socket-loader-J26QHHOB.js.map +1 -0
  65. package/dist/{socket-loader-N5ETWMXW.mjs → socket-loader-R7S2YJ2J.mjs} +2 -2
  66. package/dist/socket-loader-R7S2YJ2J.mjs.map +1 -0
  67. package/dist/{types-C_pfGZhI.d.mts → types-Bsf5kX1n.d.mts} +1 -1
  68. package/dist/{types-C_pfGZhI.d.ts → types-Bsf5kX1n.d.ts} +1 -1
  69. package/dist/{types-DxhEH2tX.d.mts → types-CNZcDIoX.d.mts} +1 -1
  70. package/dist/{types-DxhEH2tX.d.ts → types-CNZcDIoX.d.ts} +1 -1
  71. package/dist/{types-Cl2SOKHd.d.mts → types-D8i7Alvv.d.mts} +1 -1
  72. package/dist/{types-Cl2SOKHd.d.ts → types-D8i7Alvv.d.ts} +1 -1
  73. package/dist/{types-DiZVgJKD.d.mts → types-DA_Kocle.d.mts} +1 -1
  74. package/dist/{types-DiZVgJKD.d.ts → types-DA_Kocle.d.ts} +1 -1
  75. package/dist/{types-CMNYdZwT.d.mts → types-DI0jnhjJ.d.mts} +1 -1
  76. package/dist/{types-CMNYdZwT.d.ts → types-DI0jnhjJ.d.ts} +1 -1
  77. package/dist/{types-BF2v5qX3.d.mts → types-wCtRFR0Y.d.mts} +1 -1
  78. package/dist/{types-BF2v5qX3.d.ts → types-wCtRFR0Y.d.ts} +1 -1
  79. package/dist/{useEventModal-x_RZRewW.d.mts → useEventModal-Bs0W9Iy_.d.mts} +2 -2
  80. package/dist/{useEventModal-5fIKdIaY.d.ts → useEventModal-Btu3uIjE.d.ts} +2 -2
  81. package/dist/{web-vitals-PW6MQOKS.js → web-vitals-444RLW3B.js} +3 -3
  82. package/dist/web-vitals-444RLW3B.js.map +1 -0
  83. package/dist/{web-vitals-YSIFBTH7.mjs → web-vitals-KPICZIEF.mjs} +3 -3
  84. package/dist/web-vitals-KPICZIEF.mjs.map +1 -0
  85. package/package.json +2 -1
  86. package/dist/chunk-3LOFIO77.mjs.map +0 -1
  87. package/dist/chunk-C5TQLU5U.js.map +0 -1
  88. package/dist/chunk-RLO3QJ65.mjs.map +0 -1
  89. package/dist/chunk-VFJ3NNCY.js.map +0 -1
  90. package/dist/socket-loader-3FWQWPDQ.js.map +0 -1
  91. package/dist/socket-loader-N5ETWMXW.mjs.map +0 -1
  92. package/dist/web-vitals-PW6MQOKS.js.map +0 -1
  93. package/dist/web-vitals-YSIFBTH7.mjs.map +0 -1
@@ -1,4 +1,5 @@
1
1
  import React2, { useState, useRef, useEffect, useCallback, createElement } from 'react';
2
+ import ReactMarkdown from 'react-markdown';
2
3
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
3
4
  import { usePathname } from 'next/navigation';
4
5
 
@@ -19,6 +20,19 @@ function generateVisitorId() {
19
20
  if (typeof localStorage !== "undefined") localStorage.setItem("engage_visitor_id", id);
20
21
  return id;
21
22
  }
23
+ function userRequestedHandoff(text) {
24
+ const lower = text.toLowerCase().trim();
25
+ const patterns = [
26
+ /\b(talk|speak)\s+(to|with)\s+(a\s+)?(person|human|agent|representative|someone)\b/,
27
+ /\b(real|live)\s+(person|human|agent|support)\b/,
28
+ /\bconnect\s+(me\s+)?(with|to)\s+(a\s+)?(person|human|agent)\b/,
29
+ /\b(need|want)\s+(to\s+)?(talk|speak)\s+(to|with)\s+(someone|a\s+person)\b/,
30
+ /\bhuman\s+(support|agent|help)\b/,
31
+ /\b(talk|speak)\s+to\s+(a\s+)?person\b/,
32
+ /\bget\s+(a\s+)?(person|human)\b/
33
+ ];
34
+ return patterns.some((p) => p.test(lower));
35
+ }
22
36
  function adjustColor(hex, amount) {
23
37
  const num = parseInt(hex.replace("#", ""), 16);
24
38
  const r = Math.min(255, Math.max(0, (num >> 16) + amount));
@@ -214,8 +228,9 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
214
228
  const data = json?.data ?? json;
215
229
  const aiContent = data?.content ?? data?.response ?? data?.message ?? "I'm sorry, I couldn't process that.";
216
230
  const suggestions = data?.suggestions;
231
+ const offerHandoff = data?.offerHandoff === true || data?.offer_handoff === true;
217
232
  const newConversationId = data?.conversationId ?? conversationId;
218
- return { content: aiContent, suggestions, conversationId: newConversationId };
233
+ return { content: aiContent, suggestions, offerHandoff, conversationId: newConversationId };
219
234
  },
220
235
  [signalUrl, projectId, visitorId, fetchSiteContext]
221
236
  );
@@ -274,7 +289,7 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
274
289
  socketRef.current.disconnect();
275
290
  socketRef.current = null;
276
291
  }
277
- const { createSocket } = await import('./socket-loader-N5ETWMXW.mjs');
292
+ const { createSocket } = await import('./socket-loader-R7S2YJ2J.mjs');
278
293
  const namespaceUrl = `${baseUrl.replace(/\/$/, "")}/engage/chat`;
279
294
  const socket = await createSocket(namespaceUrl, {
280
295
  query: { projectId, visitorId, sessionId: currentSessionId },
@@ -421,7 +436,8 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
421
436
  { id: `u-${Date.now()}`, role: "user", content: pending, timestamp: /* @__PURE__ */ new Date() }
422
437
  ]);
423
438
  try {
424
- const { content: aiContent, suggestions } = await sendToSignalApi(pending, id);
439
+ const { content: aiContent, suggestions, offerHandoff } = await sendToSignalApi(pending, id);
440
+ const userWantsHandoff = userRequestedHandoff(pending);
425
441
  setMessages((prev) => [
426
442
  ...prev,
427
443
  {
@@ -429,7 +445,8 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
429
445
  role: "assistant",
430
446
  content: aiContent,
431
447
  timestamp: /* @__PURE__ */ new Date(),
432
- ...suggestions?.length ? { suggestions } : {}
448
+ ...suggestions?.length ? { suggestions } : {},
449
+ ...offerHandoff || userWantsHandoff ? { offerHandoff: true } : {}
433
450
  }
434
451
  ]);
435
452
  } catch (err) {
@@ -441,7 +458,8 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
441
458
  role: "assistant",
442
459
  content: "I apologize, but I encountered an error. Would you like to speak with a team member?",
443
460
  timestamp: /* @__PURE__ */ new Date(),
444
- suggestions: ["Talk to a person", "Try again"]
461
+ suggestions: ["Talk to a person", "Try again"],
462
+ offerHandoff: true
445
463
  }
446
464
  ]);
447
465
  } finally {
@@ -563,7 +581,8 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
563
581
  setIsLoading(true);
564
582
  if (widgetConfig?.signal_enabled && hasText) {
565
583
  try {
566
- const { content: aiContent, suggestions } = await sendToSignalApi(content, sessionId);
584
+ const { content: aiContent, suggestions, offerHandoff } = await sendToSignalApi(content, sessionId);
585
+ const lastUserContent = messages.filter((m) => m.role === "user").slice(-1)[0]?.content ?? "";
567
586
  setMessages((prev) => [
568
587
  ...prev,
569
588
  {
@@ -571,7 +590,8 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
571
590
  role: "assistant",
572
591
  content: aiContent,
573
592
  timestamp: /* @__PURE__ */ new Date(),
574
- ...suggestions?.length ? { suggestions } : {}
593
+ ...suggestions?.length ? { suggestions } : {},
594
+ ...offerHandoff || userRequestedHandoff(lastUserContent) ? { offerHandoff: true } : {}
575
595
  }
576
596
  ]);
577
597
  } catch (err) {
@@ -583,7 +603,8 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
583
603
  role: "assistant",
584
604
  content: "I apologize, but I encountered an error. Would you like to speak with a team member?",
585
605
  timestamp: /* @__PURE__ */ new Date(),
586
- suggestions: ["Talk to a person", "Try again"]
606
+ suggestions: ["Talk to a person", "Try again"],
607
+ offerHandoff: true
587
608
  }
588
609
  ]);
589
610
  } finally {
@@ -995,82 +1016,105 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
995
1016
  {
996
1017
  style: { flex: 1, overflowY: "auto", padding: 16, display: "flex", flexDirection: "column", gap: 12, backgroundColor: "#f9fafb" },
997
1018
  children: [
998
- messages.map((message) => /* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: message.role === "user" ? "flex-end" : "flex-start" }, children: /* @__PURE__ */ jsxs(
999
- "div",
1000
- {
1001
- style: {
1002
- maxWidth: "80%",
1003
- padding: message.role === "system" ? "8px 12px" : "10px 14px",
1004
- borderRadius: message.role === "user" ? "16px 16px 4px 16px" : message.role === "system" ? "8px" : "16px 16px 16px 4px",
1005
- backgroundColor: message.role === "user" ? primaryColor : message.role === "system" ? "#e5e7eb" : "#ffffff",
1006
- color: message.role === "user" ? isLightColor(primaryColor) ? "#1a1a1a" : "white" : message.role === "system" ? "#6b7280" : "#111827",
1007
- boxShadow: message.role === "system" ? "none" : "0 1px 2px rgba(0,0,0,0.08)",
1008
- fontSize: message.role === "system" ? 13 : 14,
1009
- fontStyle: message.role === "system" ? "italic" : "normal",
1010
- lineHeight: 1.5,
1011
- whiteSpace: "pre-wrap",
1012
- wordBreak: "break-word"
1013
- },
1014
- children: [
1015
- message.agentName && message.role === "agent" && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, opacity: 0.6, marginBottom: 4 }, children: message.agentName }),
1016
- message.content,
1017
- message.attachments?.length ? /* @__PURE__ */ jsx("div", { style: { marginTop: 8, display: "flex", flexDirection: "column", gap: 6 }, children: message.attachments.map(
1018
- (att, i) => att.mimeType?.startsWith("image/") ? /* @__PURE__ */ jsx("a", { href: att.url, target: "_blank", rel: "noopener noreferrer", style: { display: "block" }, children: /* @__PURE__ */ jsx("img", { src: att.url, alt: att.name, style: { maxWidth: "100%", maxHeight: 200, borderRadius: 8, objectFit: "contain" } }) }, i) : /* @__PURE__ */ jsxs("a", { href: att.url, target: "_blank", rel: "noopener noreferrer", style: { fontSize: 13, wordBreak: "break-all" }, children: [
1019
- "\u{1F4CE} ",
1020
- att.name
1021
- ] }, i)
1022
- ) }) : null,
1023
- message.suggestions?.length ? /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 6, marginTop: 8 }, children: message.suggestions.map((s, i) => /* @__PURE__ */ jsx(
1024
- "button",
1025
- {
1026
- type: "button",
1027
- onClick: () => {
1028
- setInputValue(s);
1029
- inputRef.current?.focus();
1030
- },
1031
- style: {
1032
- padding: "6px 12px",
1033
- borderRadius: 16,
1034
- border: `1px solid ${primaryColor}`,
1035
- backgroundColor: `${primaryColor}10`,
1036
- color: primaryColor,
1037
- fontSize: 13,
1038
- cursor: "pointer"
1039
- },
1040
- children: s
1041
- },
1042
- i
1043
- )) }) : null,
1044
- message.sendFailed && lastFailedSend && /* @__PURE__ */ jsx("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ jsx(
1045
- "button",
1046
- {
1047
- type: "button",
1048
- onClick: retryFailedSend,
1049
- style: { padding: "6px 12px", borderRadius: 6, border: "1px solid #ef4444", backgroundColor: "#fef2f2", color: "#dc2626", fontSize: 13, cursor: "pointer" },
1050
- children: "Retry send"
1051
- }
1052
- ) }),
1053
- widgetConfig?.signal_enabled && message.role === "assistant" && !message.suggestions?.length && widgetConfig?.handoff_enabled !== false && messages.filter((m) => m.role === "user").length >= 2 && message.id === messages.filter((m) => m.role === "assistant").slice(-1)[0]?.id && /* @__PURE__ */ jsx(
1054
- "button",
1055
- {
1056
- onClick: requestHandoff,
1057
- style: {
1058
- display: "inline-block",
1059
- marginTop: 8,
1060
- padding: "6px 12px",
1061
- borderRadius: 6,
1062
- border: `1px solid ${primaryColor}`,
1063
- backgroundColor: "transparent",
1064
- color: primaryColor,
1065
- fontSize: 13,
1066
- cursor: "pointer"
1019
+ messages.map((message) => {
1020
+ const isAssistant = message.role === "assistant" || message.role === "agent";
1021
+ return /* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: message.role === "user" ? "flex-end" : "flex-start" }, children: /* @__PURE__ */ jsxs(
1022
+ "div",
1023
+ {
1024
+ style: {
1025
+ maxWidth: "80%",
1026
+ padding: message.role === "system" ? "8px 12px" : isAssistant ? "12px 16px" : "10px 14px",
1027
+ borderRadius: message.role === "user" ? "16px 16px 4px 16px" : message.role === "system" ? "8px" : "16px 16px 16px 4px",
1028
+ backgroundColor: message.role === "user" ? primaryColor : message.role === "system" ? "#e5e7eb" : "#ffffff",
1029
+ color: message.role === "user" ? isLightColor(primaryColor) ? "#1a1a1a" : "white" : message.role === "system" ? "#6b7280" : "#111827",
1030
+ boxShadow: message.role === "system" ? "none" : "0 1px 2px rgba(0,0,0,0.08)",
1031
+ fontSize: message.role === "system" ? 13 : 14,
1032
+ fontStyle: message.role === "system" ? "italic" : "normal",
1033
+ lineHeight: isAssistant ? 1.6 : 1.5,
1034
+ whiteSpace: isAssistant ? "normal" : "pre-wrap",
1035
+ wordBreak: "break-word",
1036
+ textAlign: isAssistant ? "left" : void 0,
1037
+ borderLeft: isAssistant ? `3px solid ${primaryColor}33` : void 0
1038
+ },
1039
+ children: [
1040
+ message.agentName && message.role === "agent" && /* @__PURE__ */ jsx("div", { style: { fontSize: 12, opacity: 0.6, marginBottom: 4 }, children: message.agentName }),
1041
+ isAssistant ? /* @__PURE__ */ jsx("div", { className: "chatMessageContent", children: /* @__PURE__ */ jsx(
1042
+ ReactMarkdown,
1043
+ {
1044
+ components: {
1045
+ p: ({ children }) => /* @__PURE__ */ jsx("p", { style: { margin: "0 0 8px", lineHeight: 1.6 }, children }),
1046
+ strong: ({ children }) => /* @__PURE__ */ jsx("strong", { style: { fontWeight: 600 }, children }),
1047
+ ul: ({ children }) => /* @__PURE__ */ jsx("ul", { style: { margin: "4px 0 8px", paddingLeft: 20 }, children }),
1048
+ ol: ({ children }) => /* @__PURE__ */ jsx("ol", { style: { margin: "4px 0 8px", paddingLeft: 20 }, children }),
1049
+ li: ({ children }) => /* @__PURE__ */ jsx("li", { style: { marginBottom: 4 }, children }),
1050
+ h3: ({ children }) => /* @__PURE__ */ jsx("h3", { style: { margin: "12px 0 6px", fontSize: 15, fontWeight: 600 }, children }),
1051
+ h4: ({ children }) => /* @__PURE__ */ jsx("h4", { style: { margin: "8px 0 4px", fontSize: 14, fontWeight: 600 }, children })
1052
+ },
1053
+ children: message.content
1054
+ }
1055
+ ) }) : message.content,
1056
+ message.attachments?.length ? /* @__PURE__ */ jsx("div", { style: { marginTop: 8, display: "flex", flexDirection: "column", gap: 6 }, children: message.attachments.map(
1057
+ (att, i) => att.mimeType?.startsWith("image/") ? /* @__PURE__ */ jsx("a", { href: att.url, target: "_blank", rel: "noopener noreferrer", style: { display: "block" }, children: /* @__PURE__ */ jsx("img", { src: att.url, alt: att.name, style: { maxWidth: "100%", maxHeight: 200, borderRadius: 8, objectFit: "contain" } }) }, i) : /* @__PURE__ */ jsxs("a", { href: att.url, target: "_blank", rel: "noopener noreferrer", style: { fontSize: 13, wordBreak: "break-all", display: "flex", alignItems: "center", gap: 6 }, children: [
1058
+ /* @__PURE__ */ jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" }) }),
1059
+ att.name
1060
+ ] }, i)
1061
+ ) }) : null,
1062
+ message.suggestions?.length ? /* @__PURE__ */ jsx("div", { style: { display: "flex", flexWrap: "wrap", gap: 6, marginTop: 8 }, children: message.suggestions.map((s, i) => /* @__PURE__ */ jsx(
1063
+ "button",
1064
+ {
1065
+ type: "button",
1066
+ onClick: () => {
1067
+ if (/talk\s+to\s+(a\s+)?person/i.test(s)) {
1068
+ requestHandoff();
1069
+ } else {
1070
+ setInputValue(s);
1071
+ inputRef.current?.focus();
1072
+ }
1073
+ },
1074
+ style: {
1075
+ padding: "6px 12px",
1076
+ borderRadius: 16,
1077
+ border: `1px solid ${primaryColor}`,
1078
+ backgroundColor: `${primaryColor}10`,
1079
+ color: primaryColor,
1080
+ fontSize: 13,
1081
+ cursor: "pointer"
1082
+ },
1083
+ children: s
1067
1084
  },
1068
- children: "Talk to a person"
1069
- }
1070
- )
1071
- ]
1072
- }
1073
- ) }, message.id)),
1085
+ i
1086
+ )) }) : null,
1087
+ message.sendFailed && lastFailedSend && /* @__PURE__ */ jsx("div", { style: { marginTop: 8 }, children: /* @__PURE__ */ jsx(
1088
+ "button",
1089
+ {
1090
+ type: "button",
1091
+ onClick: retryFailedSend,
1092
+ style: { padding: "6px 12px", borderRadius: 6, border: "1px solid #ef4444", backgroundColor: "#fef2f2", color: "#dc2626", fontSize: 13, cursor: "pointer" },
1093
+ children: "Retry send"
1094
+ }
1095
+ ) }),
1096
+ widgetConfig?.signal_enabled && message.role === "assistant" && widgetConfig?.handoff_enabled !== false && message.offerHandoff && !message.suggestions?.some((s) => /talk\s+to\s+(a\s+)?person/i.test(s)) && message.id === messages.filter((m) => m.role === "assistant").slice(-1)[0]?.id && /* @__PURE__ */ jsx(
1097
+ "button",
1098
+ {
1099
+ onClick: requestHandoff,
1100
+ style: {
1101
+ display: "inline-block",
1102
+ marginTop: 8,
1103
+ padding: "6px 12px",
1104
+ borderRadius: 6,
1105
+ border: `1px solid ${primaryColor}`,
1106
+ backgroundColor: "transparent",
1107
+ color: primaryColor,
1108
+ fontSize: 13,
1109
+ cursor: "pointer"
1110
+ },
1111
+ children: "Talk to a person"
1112
+ }
1113
+ )
1114
+ ]
1115
+ }
1116
+ ) }, message.id);
1117
+ }),
1074
1118
  (isLoading || agentTyping) && /* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: "flex-start" }, children: /* @__PURE__ */ jsxs(
1075
1119
  "div",
1076
1120
  {
@@ -1200,6 +1244,8 @@ function ChatWidget({ projectId: propProjectId, config, apiUrl: propApiUrl, sign
1200
1244
  from { transform: scaleX(0); }
1201
1245
  to { transform: scaleX(1); }
1202
1246
  }
1247
+ .chatMessageContent p:first-child { margin-top: 0; }
1248
+ .chatMessageContent p:last-child { margin-bottom: 0; }
1203
1249
  ` })
1204
1250
  ]
1205
1251
  }
@@ -1831,5 +1877,5 @@ function getDeviceType() {
1831
1877
  }
1832
1878
 
1833
1879
  export { ChatWidget, DesignRenderer, EngageWidget };
1834
- //# sourceMappingURL=chunk-RLO3QJ65.mjs.map
1835
- //# sourceMappingURL=chunk-RLO3QJ65.mjs.map
1880
+ //# sourceMappingURL=chunk-TJBXNQ2W.mjs.map
1881
+ //# sourceMappingURL=chunk-TJBXNQ2W.mjs.map