@jrapps/my_tickets_chat_ui 0.1.1 → 0.2.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/cjs/components/SiteChatComponent/index.js +1 -1
- package/dist/cjs/components/SiteChatComponent/index.js.map +2 -2
- package/dist/cjs/components/SiteChatComponentNew/index.js +1280 -0
- package/dist/cjs/components/SiteChatComponentNew/index.js.map +7 -0
- package/dist/cjs/index.js +1247 -2
- package/dist/cjs/index.js.map +4 -4
- package/dist/esm/chunks/{chunk-XNTJKZD3.js → chunk-QPJPV2T3.js} +2 -2
- package/dist/esm/chunks/chunk-QPJPV2T3.js.map +7 -0
- package/dist/esm/chunks/chunk-TWW7V724.js +1248 -0
- package/dist/esm/chunks/chunk-TWW7V724.js.map +7 -0
- package/dist/esm/components/SiteChatComponent/index.js +1 -1
- package/dist/esm/components/SiteChatComponentNew/index.js +9 -0
- package/dist/esm/components/SiteChatComponentNew/index.js.map +7 -0
- package/dist/esm/index.js +8 -2
- package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.types.d.ts +1 -18
- package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.types.d.ts.map +1 -1
- package/dist/types/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.d.ts.map +1 -1
- package/dist/types/components/SiteChatComponentNew/Footer/Footer.d.ts +6 -0
- package/dist/types/components/SiteChatComponentNew/Footer/Footer.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Footer/index.d.ts +2 -0
- package/dist/types/components/SiteChatComponentNew/Footer/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Header/Header.d.ts +6 -0
- package/dist/types/components/SiteChatComponentNew/Header/Header.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Header/index.d.ts +2 -0
- package/dist/types/components/SiteChatComponentNew/Header/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/AgentMessage.d.ts +9 -0
- package/dist/types/components/SiteChatComponentNew/Messages/AgentMessage.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/AttachmentMessage.d.ts +9 -0
- package/dist/types/components/SiteChatComponentNew/Messages/AttachmentMessage.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/MessageList.d.ts +9 -0
- package/dist/types/components/SiteChatComponentNew/Messages/MessageList.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/MessageRenderer.d.ts +8 -0
- package/dist/types/components/SiteChatComponentNew/Messages/MessageRenderer.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/SystemMessage.d.ts +9 -0
- package/dist/types/components/SiteChatComponentNew/Messages/SystemMessage.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/TypingIndicator.d.ts +5 -0
- package/dist/types/components/SiteChatComponentNew/Messages/TypingIndicator.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/UserMessage.d.ts +9 -0
- package/dist/types/components/SiteChatComponentNew/Messages/UserMessage.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Messages/index.d.ts +8 -0
- package/dist/types/components/SiteChatComponentNew/Messages/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/OfflineForm/OfflineForm.d.ts +10 -0
- package/dist/types/components/SiteChatComponentNew/OfflineForm/OfflineForm.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/OfflineForm/index.d.ts +2 -0
- package/dist/types/components/SiteChatComponentNew/OfflineForm/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Shared/Avatar.d.ts +10 -0
- package/dist/types/components/SiteChatComponentNew/Shared/Avatar.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Shared/Button.d.ts +14 -0
- package/dist/types/components/SiteChatComponentNew/Shared/Button.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/Shared/index.d.ts +3 -0
- package/dist/types/components/SiteChatComponentNew/Shared/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.d.ts +5 -0
- package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.types.d.ts +114 -0
- package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.types.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/States/ChatEndedState.d.ts +5 -0
- package/dist/types/components/SiteChatComponentNew/States/ChatEndedState.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/States/LoadingState.d.ts +5 -0
- package/dist/types/components/SiteChatComponentNew/States/LoadingState.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/States/OfflineState.d.ts +10 -0
- package/dist/types/components/SiteChatComponentNew/States/OfflineState.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/States/StartChatState.d.ts +11 -0
- package/dist/types/components/SiteChatComponentNew/States/StartChatState.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/States/index.d.ts +5 -0
- package/dist/types/components/SiteChatComponentNew/States/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/hooks/index.d.ts +3 -0
- package/dist/types/components/SiteChatComponentNew/hooks/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/hooks/useAutoScroll.d.ts +15 -0
- package/dist/types/components/SiteChatComponentNew/hooks/useAutoScroll.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/hooks/useOfflineForm.d.ts +12 -0
- package/dist/types/components/SiteChatComponentNew/hooks/useOfflineForm.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/index.d.ts +4 -0
- package/dist/types/components/SiteChatComponentNew/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/useSiteChatComponentNew.d.ts +3 -0
- package/dist/types/components/SiteChatComponentNew/useSiteChatComponentNew.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/utils/format.d.ts +9 -0
- package/dist/types/components/SiteChatComponentNew/utils/format.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/utils/index.d.ts +4 -0
- package/dist/types/components/SiteChatComponentNew/utils/index.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/utils/systemMessages.d.ts +4 -0
- package/dist/types/components/SiteChatComponentNew/utils/systemMessages.d.ts.map +1 -0
- package/dist/types/components/SiteChatComponentNew/utils/theme.d.ts +8 -0
- package/dist/types/components/SiteChatComponentNew/utils/theme.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/esm/chunks/chunk-XNTJKZD3.js.map +0 -7
package/dist/cjs/index.js
CHANGED
|
@@ -30,7 +30,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
|
-
SiteChatComponent: () => SiteChatComponent
|
|
33
|
+
SiteChatComponent: () => SiteChatComponent,
|
|
34
|
+
SiteChatComponentNew: () => SiteChatComponentNew,
|
|
35
|
+
useSiteChatComponentNew: () => useSiteChatComponentNew
|
|
34
36
|
});
|
|
35
37
|
module.exports = __toCommonJS(src_exports);
|
|
36
38
|
|
|
@@ -368,7 +370,7 @@ var MessagesWrapper = ({ messages = [] }) => {
|
|
|
368
370
|
wrapperRef.current.scrollTop = wrapperRef.current.scrollHeight;
|
|
369
371
|
}
|
|
370
372
|
}, [messages]);
|
|
371
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-messages-wrapper", ref: wrapperRef, children: messages.map(({ _id, message, attachment, timestamp,
|
|
373
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-messages-wrapper", ref: wrapperRef, children: messages.map(({ _id, message, attachment, timestamp, senderType, senderName }, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `message-item ${senderType}`, children: senderType === "agent" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AgentMessageWrapper, { message, attachment: attachment ? Array.isArray(attachment) ? attachment[0] : attachment : void 0, timestamp, agentName: senderName }) : senderType === "user" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(UserMessageWrapper, { message, attachment: attachment ? Array.isArray(attachment) ? attachment[0] : attachment : void 0, timestamp }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SystemMessageWrapper, { message, timestamp }) }, _id || index)) });
|
|
372
374
|
};
|
|
373
375
|
var GetSystemMessage = ({ type }) => {
|
|
374
376
|
switch (type) {
|
|
@@ -995,4 +997,1247 @@ var SiteChatComponent = Object.assign(SiteChatComponentRoot, {
|
|
|
995
997
|
Footer,
|
|
996
998
|
FabButton
|
|
997
999
|
});
|
|
1000
|
+
|
|
1001
|
+
// src/components/SiteChatComponentNew/SiteChatComponentNew.tsx
|
|
1002
|
+
var import_react12 = __toESM(require("react"));
|
|
1003
|
+
|
|
1004
|
+
// src/components/SiteChatComponentNew/useSiteChatComponentNew.ts
|
|
1005
|
+
var import_react8 = require("react");
|
|
1006
|
+
function useSiteChatComponentNew(defaultOpen = false) {
|
|
1007
|
+
const [open, setOpen] = (0, import_react8.useState)(defaultOpen);
|
|
1008
|
+
const openWidget = (0, import_react8.useCallback)(() => setOpen(true), []);
|
|
1009
|
+
const closeWidget = (0, import_react8.useCallback)(() => setOpen(false), []);
|
|
1010
|
+
return { open, openWidget, closeWidget };
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
// src/components/SiteChatComponentNew/utils/theme.ts
|
|
1014
|
+
var FONT_FAMILY = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif";
|
|
1015
|
+
var FONT_SIZE = "14px";
|
|
1016
|
+
var SHADOW = "0 4px 24px rgba(0,0,0,0.12)";
|
|
1017
|
+
var WIDTH = "400px";
|
|
1018
|
+
var HEIGHT = "600px";
|
|
1019
|
+
var HEADER_HEIGHT = "64px";
|
|
1020
|
+
var defaultTheme = {
|
|
1021
|
+
primary: "#4f46e5",
|
|
1022
|
+
background: "#ffffff",
|
|
1023
|
+
surface: "#f9fafb",
|
|
1024
|
+
border: "#e5e7eb",
|
|
1025
|
+
userBubble: "#4f46e5",
|
|
1026
|
+
userText: "#ffffff",
|
|
1027
|
+
agentBubble: "#f3f4f6",
|
|
1028
|
+
agentText: "#111827",
|
|
1029
|
+
systemText: "#6b7280",
|
|
1030
|
+
inputBackground: "#ffffff",
|
|
1031
|
+
inputBorder: "#d1d5db",
|
|
1032
|
+
buttonRadius: 8,
|
|
1033
|
+
borderRadius: 12
|
|
1034
|
+
};
|
|
1035
|
+
function buildThemeVars(partial) {
|
|
1036
|
+
const theme = { ...defaultTheme, ...partial };
|
|
1037
|
+
return {
|
|
1038
|
+
// Colours
|
|
1039
|
+
"--cw-primary": theme.primary,
|
|
1040
|
+
"--cw-background": theme.background,
|
|
1041
|
+
"--cw-surface": theme.surface,
|
|
1042
|
+
"--cw-border": theme.border,
|
|
1043
|
+
"--cw-user-bubble": theme.userBubble,
|
|
1044
|
+
"--cw-user-text": theme.userText,
|
|
1045
|
+
"--cw-agent-bubble": theme.agentBubble,
|
|
1046
|
+
"--cw-agent-text": theme.agentText,
|
|
1047
|
+
"--cw-system-text": theme.systemText,
|
|
1048
|
+
"--cw-input-background": theme.inputBackground,
|
|
1049
|
+
"--cw-input-border": theme.inputBorder,
|
|
1050
|
+
// Border radii
|
|
1051
|
+
"--cw-button-radius": `${theme.buttonRadius}px`,
|
|
1052
|
+
"--cw-border-radius": `${theme.borderRadius}px`,
|
|
1053
|
+
// Fixed constants — not exposed as theme props
|
|
1054
|
+
"--cw-font-family": FONT_FAMILY,
|
|
1055
|
+
"--cw-font-size": FONT_SIZE,
|
|
1056
|
+
"--cw-shadow": SHADOW,
|
|
1057
|
+
"--cw-width": WIDTH,
|
|
1058
|
+
"--cw-height": HEIGHT,
|
|
1059
|
+
"--cw-header-height": HEADER_HEIGHT
|
|
1060
|
+
};
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// src/components/SiteChatComponentNew/utils/systemMessages.ts
|
|
1064
|
+
var systemEventLabels = {
|
|
1065
|
+
AGENT_JOINED: "Agent joined",
|
|
1066
|
+
AGENT_LEFT: "Agent left",
|
|
1067
|
+
USER_JOINED: "You joined",
|
|
1068
|
+
USER_LEFT: "You left",
|
|
1069
|
+
CHAT_ENDED: "Chat ended",
|
|
1070
|
+
CHAT_REOPENED: "Chat reopened",
|
|
1071
|
+
CHAT_TRANSFERRED: "Chat transferred",
|
|
1072
|
+
WAITING_FOR_AGENT: "Waiting for an agent"
|
|
1073
|
+
};
|
|
1074
|
+
function getSystemLabel(event) {
|
|
1075
|
+
var _a;
|
|
1076
|
+
return (_a = systemEventLabels[event]) != null ? _a : event;
|
|
1077
|
+
}
|
|
1078
|
+
|
|
1079
|
+
// src/components/SiteChatComponentNew/utils/format.ts
|
|
1080
|
+
function formatTime(timestamp) {
|
|
1081
|
+
return new Date(timestamp).toLocaleTimeString([], {
|
|
1082
|
+
hour: "2-digit",
|
|
1083
|
+
minute: "2-digit"
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
// src/components/SiteChatComponentNew/Header/Header.css
|
|
1088
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-45eba566")) {
|
|
1089
|
+
const s = document.createElement("style");
|
|
1090
|
+
s.id = "jrapps-style-45eba566";
|
|
1091
|
+
s.textContent = ".cw-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 16px;\n height: var(--cw-header-height);\n background-color: var(--cw-primary);\n color: #ffffff;\n flex-shrink: 0;\n border-radius: var(--cw-border-radius) var(--cw-border-radius) 0 0;\n}\n\n.cw-header__identity {\n display: flex;\n align-items: center;\n gap: 12px;\n min-width: 0;\n}\n\n.cw-header__avatar {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n border: 2px solid rgba(255, 255, 255, 0.4);\n}\n\n.cw-header__text {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n\n.cw-header__title {\n font-size: 15px;\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n}\n\n.cw-header__subtitle {\n font-size: 12px;\n opacity: 0.85;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n}\n\n.cw-header__close {\n background: none;\n border: none;\n cursor: pointer;\n color: #ffffff;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 6px;\n border-radius: 50%;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n}\n\n.cw-header__close:hover {\n background-color: rgba(255, 255, 255, 0.15);\n}\n\n.cw-header__close:focus-visible {\n outline: 2px solid #ffffff;\n outline-offset: 2px;\n}\n";
|
|
1092
|
+
document.head.appendChild(s);
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
// src/components/SiteChatComponentNew/Header/Header.tsx
|
|
1096
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1097
|
+
var Header2 = ({ image, title, subtitle, onClose }) => {
|
|
1098
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("header", { className: "cw-header", role: "banner", children: [
|
|
1099
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "cw-header__identity", children: [
|
|
1100
|
+
image && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1101
|
+
"img",
|
|
1102
|
+
{
|
|
1103
|
+
src: image,
|
|
1104
|
+
alt: `${title} avatar`,
|
|
1105
|
+
className: "cw-header__avatar"
|
|
1106
|
+
}
|
|
1107
|
+
),
|
|
1108
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("div", { className: "cw-header__text", children: [
|
|
1109
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "cw-header__title", children: title }),
|
|
1110
|
+
subtitle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { className: "cw-header__subtitle", children: subtitle })
|
|
1111
|
+
] })
|
|
1112
|
+
] }),
|
|
1113
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1114
|
+
"button",
|
|
1115
|
+
{
|
|
1116
|
+
className: "cw-header__close",
|
|
1117
|
+
onClick: onClose,
|
|
1118
|
+
"aria-label": "Close chat",
|
|
1119
|
+
type: "button",
|
|
1120
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
|
|
1121
|
+
"svg",
|
|
1122
|
+
{
|
|
1123
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1124
|
+
width: "20",
|
|
1125
|
+
height: "20",
|
|
1126
|
+
viewBox: "0 0 24 24",
|
|
1127
|
+
fill: "none",
|
|
1128
|
+
stroke: "currentColor",
|
|
1129
|
+
strokeWidth: "2",
|
|
1130
|
+
strokeLinecap: "round",
|
|
1131
|
+
strokeLinejoin: "round",
|
|
1132
|
+
"aria-hidden": "true",
|
|
1133
|
+
children: [
|
|
1134
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
1135
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
1136
|
+
]
|
|
1137
|
+
}
|
|
1138
|
+
)
|
|
1139
|
+
}
|
|
1140
|
+
)
|
|
1141
|
+
] });
|
|
1142
|
+
};
|
|
1143
|
+
var Header_default = Header2;
|
|
1144
|
+
|
|
1145
|
+
// src/components/SiteChatComponentNew/Footer/Footer.tsx
|
|
1146
|
+
var import_react9 = require("react");
|
|
1147
|
+
|
|
1148
|
+
// src/components/SiteChatComponentNew/Footer/Footer.css
|
|
1149
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-ebcf221d")) {
|
|
1150
|
+
const s = document.createElement("style");
|
|
1151
|
+
s.id = "jrapps-style-ebcf221d";
|
|
1152
|
+
s.textContent = ".cw-footer {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n padding: 10px 12px;\n background-color: var(--cw-background);\n border-top: 1px solid var(--cw-border);\n flex-shrink: 0;\n}\n\n.cw-footer__input {\n flex: 1;\n resize: none;\n border: 1px solid var(--cw-input-border);\n border-radius: var(--cw-button-radius);\n background-color: var(--cw-input-background);\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n color: inherit;\n padding: 8px 12px;\n line-height: 1.5;\n min-height: 38px;\n max-height: 120px;\n overflow-y: auto;\n transition: border-color 0.15s ease;\n}\n\n.cw-footer__input:focus {\n outline: none;\n border-color: var(--cw-primary);\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);\n}\n\n.cw-footer__input:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.cw-footer__attach-btn,\n.cw-footer__send-btn {\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 8px;\n border-radius: 50%;\n flex-shrink: 0;\n transition: background-color 0.15s ease, color 0.15s ease;\n color: var(--cw-primary);\n margin-bottom: 1px;\n}\n\n.cw-footer__attach-btn:hover,\n.cw-footer__send-btn:not(.cw-footer__send-btn--disabled):hover {\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n}\n\n.cw-footer__attach-btn:focus-visible,\n.cw-footer__send-btn:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 2px;\n}\n\n.cw-footer__attach-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.cw-footer__send-btn--disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n.cw-footer__file-input {\n display: none;\n}\n";
|
|
1153
|
+
document.head.appendChild(s);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
// src/components/SiteChatComponentNew/Footer/Footer.tsx
|
|
1157
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1158
|
+
var Footer2 = ({ onSend, onAttachment, disabled }) => {
|
|
1159
|
+
const [text, setText] = (0, import_react9.useState)("");
|
|
1160
|
+
const fileInputRef = (0, import_react9.useRef)(null);
|
|
1161
|
+
const textareaRef = (0, import_react9.useRef)(null);
|
|
1162
|
+
const isEmpty = text.trim().length === 0;
|
|
1163
|
+
const handleKeyDown = (0, import_react9.useCallback)(
|
|
1164
|
+
(e) => {
|
|
1165
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
1166
|
+
e.preventDefault();
|
|
1167
|
+
if (!isEmpty && !disabled) {
|
|
1168
|
+
onSend(text.trim());
|
|
1169
|
+
setText("");
|
|
1170
|
+
if (textareaRef.current) {
|
|
1171
|
+
textareaRef.current.style.height = "auto";
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
},
|
|
1176
|
+
[isEmpty, disabled, onSend, text]
|
|
1177
|
+
);
|
|
1178
|
+
const handleSend = (0, import_react9.useCallback)(() => {
|
|
1179
|
+
if (!isEmpty && !disabled) {
|
|
1180
|
+
onSend(text.trim());
|
|
1181
|
+
setText("");
|
|
1182
|
+
if (textareaRef.current) {
|
|
1183
|
+
textareaRef.current.style.height = "auto";
|
|
1184
|
+
textareaRef.current.focus();
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
}, [isEmpty, disabled, onSend, text]);
|
|
1188
|
+
const handleChange = (0, import_react9.useCallback)(
|
|
1189
|
+
(e) => {
|
|
1190
|
+
setText(e.target.value);
|
|
1191
|
+
const el = e.target;
|
|
1192
|
+
el.style.height = "auto";
|
|
1193
|
+
el.style.height = `${Math.min(el.scrollHeight, 120)}px`;
|
|
1194
|
+
},
|
|
1195
|
+
[]
|
|
1196
|
+
);
|
|
1197
|
+
const handleAttachmentClick = (0, import_react9.useCallback)(() => {
|
|
1198
|
+
var _a;
|
|
1199
|
+
(_a = fileInputRef.current) == null ? void 0 : _a.click();
|
|
1200
|
+
}, []);
|
|
1201
|
+
const handleFileChange = (0, import_react9.useCallback)(
|
|
1202
|
+
(e) => {
|
|
1203
|
+
var _a;
|
|
1204
|
+
const file = (_a = e.target.files) == null ? void 0 : _a[0];
|
|
1205
|
+
if (file) {
|
|
1206
|
+
onAttachment(file);
|
|
1207
|
+
}
|
|
1208
|
+
if (fileInputRef.current) {
|
|
1209
|
+
fileInputRef.current.value = "";
|
|
1210
|
+
}
|
|
1211
|
+
},
|
|
1212
|
+
[onAttachment]
|
|
1213
|
+
);
|
|
1214
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("footer", { className: "cw-footer", role: "contentinfo", children: [
|
|
1215
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1216
|
+
"button",
|
|
1217
|
+
{
|
|
1218
|
+
className: "cw-footer__attach-btn",
|
|
1219
|
+
onClick: handleAttachmentClick,
|
|
1220
|
+
"aria-label": "Attach file",
|
|
1221
|
+
type: "button",
|
|
1222
|
+
disabled,
|
|
1223
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1224
|
+
"svg",
|
|
1225
|
+
{
|
|
1226
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1227
|
+
width: "20",
|
|
1228
|
+
height: "20",
|
|
1229
|
+
viewBox: "0 0 24 24",
|
|
1230
|
+
fill: "none",
|
|
1231
|
+
stroke: "currentColor",
|
|
1232
|
+
strokeWidth: "2",
|
|
1233
|
+
strokeLinecap: "round",
|
|
1234
|
+
strokeLinejoin: "round",
|
|
1235
|
+
"aria-hidden": "true",
|
|
1236
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.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" })
|
|
1237
|
+
}
|
|
1238
|
+
)
|
|
1239
|
+
}
|
|
1240
|
+
),
|
|
1241
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1242
|
+
"textarea",
|
|
1243
|
+
{
|
|
1244
|
+
ref: textareaRef,
|
|
1245
|
+
className: "cw-footer__input",
|
|
1246
|
+
value: text,
|
|
1247
|
+
onChange: handleChange,
|
|
1248
|
+
onKeyDown: handleKeyDown,
|
|
1249
|
+
placeholder: "Type a message\u2026",
|
|
1250
|
+
"aria-label": "Message input",
|
|
1251
|
+
rows: 1,
|
|
1252
|
+
disabled
|
|
1253
|
+
}
|
|
1254
|
+
),
|
|
1255
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1256
|
+
"button",
|
|
1257
|
+
{
|
|
1258
|
+
className: `cw-footer__send-btn${isEmpty || disabled ? " cw-footer__send-btn--disabled" : ""}`,
|
|
1259
|
+
onClick: handleSend,
|
|
1260
|
+
"aria-label": "Send message",
|
|
1261
|
+
type: "button",
|
|
1262
|
+
disabled: isEmpty || disabled,
|
|
1263
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1264
|
+
"svg",
|
|
1265
|
+
{
|
|
1266
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1267
|
+
width: "20",
|
|
1268
|
+
height: "20",
|
|
1269
|
+
viewBox: "0 0 24 24",
|
|
1270
|
+
fill: "currentColor",
|
|
1271
|
+
"aria-hidden": "true",
|
|
1272
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" })
|
|
1273
|
+
}
|
|
1274
|
+
)
|
|
1275
|
+
}
|
|
1276
|
+
),
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1278
|
+
"input",
|
|
1279
|
+
{
|
|
1280
|
+
ref: fileInputRef,
|
|
1281
|
+
type: "file",
|
|
1282
|
+
className: "cw-footer__file-input",
|
|
1283
|
+
onChange: handleFileChange,
|
|
1284
|
+
"aria-hidden": "true",
|
|
1285
|
+
tabIndex: -1
|
|
1286
|
+
}
|
|
1287
|
+
)
|
|
1288
|
+
] });
|
|
1289
|
+
};
|
|
1290
|
+
var Footer_default = Footer2;
|
|
1291
|
+
|
|
1292
|
+
// src/components/SiteChatComponentNew/hooks/useAutoScroll.ts
|
|
1293
|
+
var import_react10 = require("react");
|
|
1294
|
+
function useAutoScroll(dependency) {
|
|
1295
|
+
const ref = (0, import_react10.useRef)(null);
|
|
1296
|
+
const userScrolledUp = (0, import_react10.useRef)(false);
|
|
1297
|
+
(0, import_react10.useEffect)(() => {
|
|
1298
|
+
const el = ref.current;
|
|
1299
|
+
if (!el) return;
|
|
1300
|
+
const handleScroll = () => {
|
|
1301
|
+
const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 64;
|
|
1302
|
+
userScrolledUp.current = !atBottom;
|
|
1303
|
+
};
|
|
1304
|
+
el.addEventListener("scroll", handleScroll, { passive: true });
|
|
1305
|
+
return () => el.removeEventListener("scroll", handleScroll);
|
|
1306
|
+
}, []);
|
|
1307
|
+
(0, import_react10.useEffect)(() => {
|
|
1308
|
+
const el = ref.current;
|
|
1309
|
+
if (!el || userScrolledUp.current) return;
|
|
1310
|
+
el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
|
|
1311
|
+
}, [dependency]);
|
|
1312
|
+
return ref;
|
|
1313
|
+
}
|
|
1314
|
+
|
|
1315
|
+
// src/components/SiteChatComponentNew/hooks/useOfflineForm.ts
|
|
1316
|
+
var import_react11 = require("react");
|
|
1317
|
+
function validateField(field, value) {
|
|
1318
|
+
if (field.required) {
|
|
1319
|
+
if (field.type === "checkbox" && !value) {
|
|
1320
|
+
return `${field.label} is required.`;
|
|
1321
|
+
}
|
|
1322
|
+
if (field.type !== "checkbox" && (value === void 0 || value === null || String(value).trim() === "")) {
|
|
1323
|
+
return `${field.label} is required.`;
|
|
1324
|
+
}
|
|
1325
|
+
}
|
|
1326
|
+
if (field.type === "email") {
|
|
1327
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
1328
|
+
if (value && !emailRegex.test(String(value))) {
|
|
1329
|
+
return "Please enter a valid email address.";
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
if (field.type === "phone") {
|
|
1333
|
+
const phoneRegex = /^\+?[\d\s\-().]{7,20}$/;
|
|
1334
|
+
if (value && !phoneRegex.test(String(value))) {
|
|
1335
|
+
return "Please enter a valid phone number.";
|
|
1336
|
+
}
|
|
1337
|
+
}
|
|
1338
|
+
return "";
|
|
1339
|
+
}
|
|
1340
|
+
function useOfflineForm(schema) {
|
|
1341
|
+
const initialValues = {};
|
|
1342
|
+
for (const field of schema.fields) {
|
|
1343
|
+
initialValues[field.id] = field.type === "checkbox" ? false : "";
|
|
1344
|
+
}
|
|
1345
|
+
const [values, setValues] = (0, import_react11.useState)(initialValues);
|
|
1346
|
+
const [errors, setErrors] = (0, import_react11.useState)({});
|
|
1347
|
+
const [submitted, setSubmitted] = (0, import_react11.useState)(false);
|
|
1348
|
+
const setValue = (0, import_react11.useCallback)(
|
|
1349
|
+
(id, value) => {
|
|
1350
|
+
setValues((prev) => ({ ...prev, [id]: value }));
|
|
1351
|
+
if (submitted) {
|
|
1352
|
+
const field = schema.fields.find((f) => f.id === id);
|
|
1353
|
+
if (field) {
|
|
1354
|
+
const error = validateField(field, value);
|
|
1355
|
+
setErrors((prev) => ({ ...prev, [id]: error }));
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
},
|
|
1359
|
+
[schema.fields, submitted]
|
|
1360
|
+
);
|
|
1361
|
+
const validate = (0, import_react11.useCallback)(() => {
|
|
1362
|
+
const newErrors = {};
|
|
1363
|
+
let valid = true;
|
|
1364
|
+
for (const field of schema.fields) {
|
|
1365
|
+
const error = validateField(field, values[field.id]);
|
|
1366
|
+
newErrors[field.id] = error;
|
|
1367
|
+
if (error) valid = false;
|
|
1368
|
+
}
|
|
1369
|
+
setErrors(newErrors);
|
|
1370
|
+
return valid;
|
|
1371
|
+
}, [schema.fields, values]);
|
|
1372
|
+
const handleSubmit = (0, import_react11.useCallback)(
|
|
1373
|
+
(onSubmit) => {
|
|
1374
|
+
setSubmitted(true);
|
|
1375
|
+
if (validate()) {
|
|
1376
|
+
onSubmit(values);
|
|
1377
|
+
}
|
|
1378
|
+
},
|
|
1379
|
+
[validate, values]
|
|
1380
|
+
);
|
|
1381
|
+
const reset = (0, import_react11.useCallback)(() => {
|
|
1382
|
+
setValues(initialValues);
|
|
1383
|
+
setErrors({});
|
|
1384
|
+
setSubmitted(false);
|
|
1385
|
+
}, []);
|
|
1386
|
+
return { values, errors, setValue, handleSubmit, reset };
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
// src/components/SiteChatComponentNew/Messages/UserMessage.css
|
|
1390
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-aed321e0")) {
|
|
1391
|
+
const s = document.createElement("style");
|
|
1392
|
+
s.id = "jrapps-style-aed321e0";
|
|
1393
|
+
s.textContent = ".cw-user-message {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n max-width: 75%;\n align-self: flex-end;\n gap: 3px;\n}\n\n.cw-user-message__bubble {\n background-color: var(--cw-user-bubble);\n color: var(--cw-user-text);\n padding: 10px 14px;\n border-radius: 18px 18px 4px 18px;\n font-size: var(--cw-font-size);\n line-height: 1.5;\n word-break: break-word;\n white-space: pre-wrap;\n}\n\n.cw-user-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-right: 2px;\n}\n";
|
|
1394
|
+
document.head.appendChild(s);
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
// src/components/SiteChatComponentNew/Messages/UserMessage.tsx
|
|
1398
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1399
|
+
var UserMessage = ({ message }) => {
|
|
1400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "cw-user-message", role: "listitem", "aria-label": "Your message", children: [
|
|
1401
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "cw-user-message__bubble", children: message.message }),
|
|
1402
|
+
message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "cw-user-message__time", children: formatTime(message.timestamp) })
|
|
1403
|
+
] });
|
|
1404
|
+
};
|
|
1405
|
+
var UserMessage_default = UserMessage;
|
|
1406
|
+
|
|
1407
|
+
// src/components/SiteChatComponentNew/Shared/Avatar.css
|
|
1408
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-ce14fbec")) {
|
|
1409
|
+
const s = document.createElement("style");
|
|
1410
|
+
s.id = "jrapps-style-ce14fbec";
|
|
1411
|
+
s.textContent = ".cw-avatar {\n border-radius: 50%;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n}\n\n.cw-avatar--image {\n object-fit: cover;\n}\n\n.cw-avatar--initials {\n background-color: var(--cw-primary);\n color: #ffffff;\n font-weight: 600;\n user-select: none;\n}\n";
|
|
1412
|
+
document.head.appendChild(s);
|
|
1413
|
+
}
|
|
1414
|
+
|
|
1415
|
+
// src/components/SiteChatComponentNew/Shared/Avatar.tsx
|
|
1416
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1417
|
+
function getInitials(name) {
|
|
1418
|
+
return name.split(" ").slice(0, 2).map((w) => w[0]).join("").toUpperCase();
|
|
1419
|
+
}
|
|
1420
|
+
var Avatar2 = ({ src, name, size = 32 }) => {
|
|
1421
|
+
const style = {
|
|
1422
|
+
width: `${size}px`,
|
|
1423
|
+
height: `${size}px`,
|
|
1424
|
+
fontSize: `${Math.round(size * 0.38)}px`
|
|
1425
|
+
};
|
|
1426
|
+
if (src) {
|
|
1427
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1428
|
+
"img",
|
|
1429
|
+
{
|
|
1430
|
+
src,
|
|
1431
|
+
alt: name ? `${name} avatar` : "Agent avatar",
|
|
1432
|
+
className: "cw-avatar cw-avatar--image",
|
|
1433
|
+
style
|
|
1434
|
+
}
|
|
1435
|
+
);
|
|
1436
|
+
}
|
|
1437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1438
|
+
"span",
|
|
1439
|
+
{
|
|
1440
|
+
className: "cw-avatar cw-avatar--initials",
|
|
1441
|
+
"aria-label": name ? `${name} avatar` : "Agent avatar",
|
|
1442
|
+
style,
|
|
1443
|
+
children: name ? getInitials(name) : "A"
|
|
1444
|
+
}
|
|
1445
|
+
);
|
|
1446
|
+
};
|
|
1447
|
+
var Avatar_default = Avatar2;
|
|
1448
|
+
|
|
1449
|
+
// src/components/SiteChatComponentNew/Shared/Button.css
|
|
1450
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-2aa106ea")) {
|
|
1451
|
+
const s = document.createElement("style");
|
|
1452
|
+
s.id = "jrapps-style-2aa106ea";
|
|
1453
|
+
s.textContent = ".cw-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 10px 20px;\n border: none;\n border-radius: var(--cw-button-radius);\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n font-weight: 600;\n cursor: pointer;\n transition: opacity 0.15s ease, transform 0.1s ease;\n white-space: nowrap;\n}\n\n.cw-button:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 3px;\n}\n\n.cw-button:active:not(:disabled) {\n transform: scale(0.98);\n}\n\n.cw-button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n\n.cw-button--primary {\n background-color: var(--cw-primary);\n color: #ffffff;\n}\n\n.cw-button--primary:hover:not(:disabled) {\n opacity: 0.88;\n}\n\n.cw-button--secondary {\n background-color: var(--cw-surface);\n color: var(--cw-primary);\n border: 1px solid var(--cw-border);\n}\n\n.cw-button--secondary:hover:not(:disabled) {\n background-color: var(--cw-border);\n}\n\n.cw-button--full {\n width: 100%;\n}\n";
|
|
1454
|
+
document.head.appendChild(s);
|
|
1455
|
+
}
|
|
1456
|
+
|
|
1457
|
+
// src/components/SiteChatComponentNew/Shared/Button.tsx
|
|
1458
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1459
|
+
var Button = ({
|
|
1460
|
+
children,
|
|
1461
|
+
onClick,
|
|
1462
|
+
variant = "primary",
|
|
1463
|
+
disabled = false,
|
|
1464
|
+
type = "button",
|
|
1465
|
+
fullWidth = false,
|
|
1466
|
+
ariaLabel
|
|
1467
|
+
}) => {
|
|
1468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1469
|
+
"button",
|
|
1470
|
+
{
|
|
1471
|
+
className: `cw-button cw-button--${variant}${fullWidth ? " cw-button--full" : ""}`,
|
|
1472
|
+
onClick,
|
|
1473
|
+
disabled,
|
|
1474
|
+
type,
|
|
1475
|
+
"aria-label": ariaLabel,
|
|
1476
|
+
children
|
|
1477
|
+
}
|
|
1478
|
+
);
|
|
1479
|
+
};
|
|
1480
|
+
var Button_default = Button;
|
|
1481
|
+
|
|
1482
|
+
// src/components/SiteChatComponentNew/Messages/AgentMessage.css
|
|
1483
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-5df522b1")) {
|
|
1484
|
+
const s = document.createElement("style");
|
|
1485
|
+
s.id = "jrapps-style-5df522b1";
|
|
1486
|
+
s.textContent = ".cw-agent-message {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n max-width: 75%;\n align-self: flex-start;\n}\n\n.cw-agent-message__content {\n display: flex;\n flex-direction: column;\n gap: 3px;\n}\n\n.cw-agent-message__name {\n font-size: 11px;\n font-weight: 600;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n\n.cw-agent-message__bubble {\n background-color: var(--cw-agent-bubble);\n color: var(--cw-agent-text);\n padding: 10px 14px;\n border-radius: 18px 18px 18px 4px;\n font-size: var(--cw-font-size);\n line-height: 1.5;\n word-break: break-word;\n white-space: pre-wrap;\n}\n\n.cw-agent-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n";
|
|
1487
|
+
document.head.appendChild(s);
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
// src/components/SiteChatComponentNew/Messages/AgentMessage.tsx
|
|
1491
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1492
|
+
var AgentMessage = ({ message }) => {
|
|
1493
|
+
var _a;
|
|
1494
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1495
|
+
"div",
|
|
1496
|
+
{
|
|
1497
|
+
className: "cw-agent-message",
|
|
1498
|
+
role: "listitem",
|
|
1499
|
+
"aria-label": `Message from ${(_a = message.senderName) != null ? _a : "Agent"}`,
|
|
1500
|
+
children: [
|
|
1501
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Avatar_default, { name: message.senderName, size: 32 }),
|
|
1502
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "cw-agent-message__content", children: [
|
|
1503
|
+
message.senderName && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "cw-agent-message__name", children: message.senderName }),
|
|
1504
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "cw-agent-message__bubble", children: message.message }),
|
|
1505
|
+
message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "cw-agent-message__time", children: formatTime(message.timestamp) })
|
|
1506
|
+
] })
|
|
1507
|
+
]
|
|
1508
|
+
}
|
|
1509
|
+
);
|
|
1510
|
+
};
|
|
1511
|
+
var AgentMessage_default = AgentMessage;
|
|
1512
|
+
|
|
1513
|
+
// src/components/SiteChatComponentNew/Messages/SystemMessage.css
|
|
1514
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-464a3601")) {
|
|
1515
|
+
const s = document.createElement("style");
|
|
1516
|
+
s.id = "jrapps-style-464a3601";
|
|
1517
|
+
s.textContent = ".cw-system-message {\n display: flex;\n align-items: center;\n gap: 10px;\n align-self: stretch;\n padding: 4px 8px;\n}\n\n.cw-system-message__line {\n flex: 1;\n border-top: 1px dashed var(--cw-border);\n}\n\n.cw-system-message__text {\n font-size: 11px;\n color: var(--cw-system-text);\n white-space: nowrap;\n flex-shrink: 0;\n font-style: italic;\n}\n";
|
|
1518
|
+
document.head.appendChild(s);
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
// src/components/SiteChatComponentNew/Messages/SystemMessage.tsx
|
|
1522
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1523
|
+
var SystemMessage = ({ message }) => {
|
|
1524
|
+
var _a;
|
|
1525
|
+
const label = message.message ? getSystemLabel(message.message) : (_a = message.message) != null ? _a : "";
|
|
1526
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
|
|
1527
|
+
"div",
|
|
1528
|
+
{
|
|
1529
|
+
className: "cw-system-message",
|
|
1530
|
+
role: "listitem",
|
|
1531
|
+
"aria-label": `System notification: ${label}`,
|
|
1532
|
+
children: [
|
|
1533
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "cw-system-message__line", "aria-hidden": "true" }),
|
|
1534
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "cw-system-message__text", children: label }),
|
|
1535
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "cw-system-message__line", "aria-hidden": "true" })
|
|
1536
|
+
]
|
|
1537
|
+
}
|
|
1538
|
+
);
|
|
1539
|
+
};
|
|
1540
|
+
var SystemMessage_default = SystemMessage;
|
|
1541
|
+
|
|
1542
|
+
// src/components/SiteChatComponentNew/Messages/AttachmentMessage.css
|
|
1543
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-dd846dee")) {
|
|
1544
|
+
const s = document.createElement("style");
|
|
1545
|
+
s.id = "jrapps-style-dd846dee";
|
|
1546
|
+
s.textContent = ".cw-attachment-message {\n display: flex;\n flex-direction: column;\n gap: 3px;\n align-self: flex-start;\n max-width: 80%;\n}\n\n.cw-attachment-message--user {\n align-self: flex-end;\n align-items: flex-end;\n}\n\n.cw-attachment-message__card {\n display: flex;\n align-items: center;\n gap: 10px;\n background-color: var(--cw-agent-bubble);\n border: 1px solid var(--cw-border);\n border-radius: 12px;\n padding: 10px 14px;\n}\n\n.cw-attachment-message--user .cw-attachment-message__card {\n background-color: var(--cw-user-bubble);\n border-color: transparent;\n color: var(--cw-user-text);\n}\n\n.cw-attachment-message__icon {\n flex-shrink: 0;\n opacity: 0.75;\n display: flex;\n align-items: center;\n}\n\n.cw-attachment-message__info {\n display: flex;\n flex-direction: column;\n min-width: 0;\n flex: 1;\n}\n\n.cw-attachment-message__name {\n font-size: 13px;\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.cw-attachment-message__label {\n font-size: 11px;\n opacity: 0.65;\n}\n\n.cw-attachment-message__open-btn {\n background-color: var(--cw-primary);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n padding: 5px 12px;\n font-family: var(--cw-font-family);\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n flex-shrink: 0;\n transition: opacity 0.15s ease;\n}\n\n.cw-attachment-message--user .cw-attachment-message__open-btn {\n background-color: rgba(255, 255, 255, 0.25);\n color: #ffffff;\n}\n\n.cw-attachment-message__open-btn:hover {\n opacity: 0.85;\n}\n\n.cw-attachment-message__open-btn:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 2px;\n}\n\n.cw-attachment-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n\n.cw-attachment-message__time--right {\n padding-left: 0;\n padding-right: 2px;\n align-self: flex-end;\n}\n";
|
|
1547
|
+
document.head.appendChild(s);
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
// src/components/SiteChatComponentNew/Messages/AttachmentMessage.tsx
|
|
1551
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1552
|
+
var AttachmentMessage = ({ message }) => {
|
|
1553
|
+
var _a;
|
|
1554
|
+
const attachment = (_a = message.item) != null ? _a : message.attachment;
|
|
1555
|
+
if (!attachment) return null;
|
|
1556
|
+
const handleOpen = () => {
|
|
1557
|
+
window.open(attachment.url, "_blank", "noopener,noreferrer");
|
|
1558
|
+
};
|
|
1559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1560
|
+
"div",
|
|
1561
|
+
{
|
|
1562
|
+
className: `cw-attachment-message${message.senderType === "user" ? " cw-attachment-message--user" : ""}`,
|
|
1563
|
+
role: "listitem",
|
|
1564
|
+
"aria-label": `Attachment: ${attachment.name}`,
|
|
1565
|
+
children: [
|
|
1566
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "cw-attachment-message__card", children: [
|
|
1567
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "cw-attachment-message__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1568
|
+
"svg",
|
|
1569
|
+
{
|
|
1570
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1571
|
+
width: "24",
|
|
1572
|
+
height: "24",
|
|
1573
|
+
viewBox: "0 0 24 24",
|
|
1574
|
+
fill: "none",
|
|
1575
|
+
stroke: "currentColor",
|
|
1576
|
+
strokeWidth: "2",
|
|
1577
|
+
strokeLinecap: "round",
|
|
1578
|
+
strokeLinejoin: "round",
|
|
1579
|
+
children: [
|
|
1580
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
|
|
1581
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("polyline", { points: "14 2 14 8 20 8" })
|
|
1582
|
+
]
|
|
1583
|
+
}
|
|
1584
|
+
) }),
|
|
1585
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "cw-attachment-message__info", children: [
|
|
1586
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "cw-attachment-message__name", children: attachment.name }),
|
|
1587
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "cw-attachment-message__label", children: "Attachment" })
|
|
1588
|
+
] }),
|
|
1589
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1590
|
+
"button",
|
|
1591
|
+
{
|
|
1592
|
+
className: "cw-attachment-message__open-btn",
|
|
1593
|
+
onClick: handleOpen,
|
|
1594
|
+
"aria-label": `Open attachment ${attachment.name}`,
|
|
1595
|
+
type: "button",
|
|
1596
|
+
children: "Open"
|
|
1597
|
+
}
|
|
1598
|
+
)
|
|
1599
|
+
] }),
|
|
1600
|
+
message.timestamp !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1601
|
+
"span",
|
|
1602
|
+
{
|
|
1603
|
+
className: `cw-attachment-message__time${message.senderType === "user" ? " cw-attachment-message__time--right" : ""}`,
|
|
1604
|
+
children: formatTime(message.timestamp)
|
|
1605
|
+
}
|
|
1606
|
+
)
|
|
1607
|
+
]
|
|
1608
|
+
}
|
|
1609
|
+
);
|
|
1610
|
+
};
|
|
1611
|
+
var AttachmentMessage_default = AttachmentMessage;
|
|
1612
|
+
|
|
1613
|
+
// src/components/SiteChatComponentNew/Messages/MessageRenderer.tsx
|
|
1614
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1615
|
+
var MessageRenderer = ({ message }) => {
|
|
1616
|
+
if (message.messageType === "ATTACHMENT") {
|
|
1617
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AttachmentMessage_default, { message });
|
|
1618
|
+
}
|
|
1619
|
+
switch (message.senderType) {
|
|
1620
|
+
case "user":
|
|
1621
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(UserMessage_default, { message });
|
|
1622
|
+
case "agent":
|
|
1623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AgentMessage_default, { message });
|
|
1624
|
+
case "system":
|
|
1625
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SystemMessage_default, { message });
|
|
1626
|
+
default:
|
|
1627
|
+
return null;
|
|
1628
|
+
}
|
|
1629
|
+
};
|
|
1630
|
+
var MessageRenderer_default = MessageRenderer;
|
|
1631
|
+
|
|
1632
|
+
// src/components/SiteChatComponentNew/Messages/MessageList.css
|
|
1633
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-15ae1a6b")) {
|
|
1634
|
+
const s = document.createElement("style");
|
|
1635
|
+
s.id = "jrapps-style-15ae1a6b";
|
|
1636
|
+
s.textContent = ".cw-message-list {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 10px;\n overflow-y: auto;\n padding: 16px;\n background-color: var(--cw-background);\n scroll-behavior: smooth;\n}\n\n/* Scrollbar styling */\n.cw-message-list::-webkit-scrollbar {\n width: 5px;\n}\n\n.cw-message-list::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.cw-message-list::-webkit-scrollbar-thumb {\n background-color: var(--cw-border);\n border-radius: 10px;\n}\n";
|
|
1637
|
+
document.head.appendChild(s);
|
|
1638
|
+
}
|
|
1639
|
+
|
|
1640
|
+
// src/components/SiteChatComponentNew/Messages/MessageList.tsx
|
|
1641
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1642
|
+
var MessageList = ({ messages }) => {
|
|
1643
|
+
const scrollRef = useAutoScroll(messages);
|
|
1644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1645
|
+
"div",
|
|
1646
|
+
{
|
|
1647
|
+
ref: scrollRef,
|
|
1648
|
+
className: "cw-message-list",
|
|
1649
|
+
role: "list",
|
|
1650
|
+
"aria-label": "Chat messages",
|
|
1651
|
+
"aria-live": "polite",
|
|
1652
|
+
"aria-relevant": "additions",
|
|
1653
|
+
children: messages.map((msg, index) => {
|
|
1654
|
+
var _a, _b;
|
|
1655
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1656
|
+
MessageRenderer_default,
|
|
1657
|
+
{
|
|
1658
|
+
message: msg
|
|
1659
|
+
},
|
|
1660
|
+
(_b = msg._id) != null ? _b : `${(_a = msg.timestamp) != null ? _a : index}-${index}`
|
|
1661
|
+
);
|
|
1662
|
+
})
|
|
1663
|
+
}
|
|
1664
|
+
);
|
|
1665
|
+
};
|
|
1666
|
+
var MessageList_default = MessageList;
|
|
1667
|
+
|
|
1668
|
+
// src/components/SiteChatComponentNew/Messages/TypingIndicator.css
|
|
1669
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-4b0ca05b")) {
|
|
1670
|
+
const s = document.createElement("style");
|
|
1671
|
+
s.id = "jrapps-style-4b0ca05b";
|
|
1672
|
+
s.textContent = "@keyframes cw-bounce {\n 0%, 60%, 100% {\n transform: translateY(0);\n }\n 30% {\n transform: translateY(-6px);\n }\n}\n\n.cw-typing-indicator {\n align-self: flex-start;\n}\n\n.cw-typing-indicator__bubble {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n background-color: var(--cw-agent-bubble);\n border-radius: 18px 18px 18px 4px;\n padding: 10px 14px;\n}\n\n.cw-typing-indicator__dot {\n display: block;\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background-color: var(--cw-system-text);\n animation: cw-bounce 1.2s infinite ease-in-out;\n}\n\n.cw-typing-indicator__dot:nth-child(2) {\n animation-delay: 0.2s;\n}\n\n.cw-typing-indicator__dot:nth-child(3) {\n animation-delay: 0.4s;\n}\n";
|
|
1673
|
+
document.head.appendChild(s);
|
|
1674
|
+
}
|
|
1675
|
+
|
|
1676
|
+
// src/components/SiteChatComponentNew/Messages/TypingIndicator.tsx
|
|
1677
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1678
|
+
|
|
1679
|
+
// src/components/SiteChatComponentNew/States/LoadingState.css
|
|
1680
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-7a5a4f05")) {
|
|
1681
|
+
const s = document.createElement("style");
|
|
1682
|
+
s.id = "jrapps-style-7a5a4f05";
|
|
1683
|
+
s.textContent = "@keyframes cw-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.cw-loading-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 12px;\n}\n\n.cw-loading-state__spinner {\n width: 48px;\n height: 48px;\n}\n\n.cw-loading-state__spinner-ring {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n border: 3px solid var(--cw-border);\n border-top-color: var(--cw-primary);\n animation: cw-spin 0.8s linear infinite;\n}\n\n.cw-loading-state__title {\n font-size: 16px;\n font-weight: 600;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-loading-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 240px;\n line-height: 1.5;\n}\n";
|
|
1684
|
+
document.head.appendChild(s);
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
// src/components/SiteChatComponentNew/States/LoadingState.tsx
|
|
1688
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1689
|
+
var LoadingState = () => {
|
|
1690
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)(
|
|
1691
|
+
"div",
|
|
1692
|
+
{
|
|
1693
|
+
className: "cw-loading-state",
|
|
1694
|
+
role: "status",
|
|
1695
|
+
"aria-label": "Connecting to chat",
|
|
1696
|
+
children: [
|
|
1697
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "cw-loading-state__spinner", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "cw-loading-state__spinner-ring" }) }),
|
|
1698
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "cw-loading-state__title", children: "Connecting\u2026" }),
|
|
1699
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("p", { className: "cw-loading-state__subtitle", children: "Please wait while we connect you to an available agent." })
|
|
1700
|
+
]
|
|
1701
|
+
}
|
|
1702
|
+
);
|
|
1703
|
+
};
|
|
1704
|
+
var LoadingState_default = LoadingState;
|
|
1705
|
+
|
|
1706
|
+
// src/components/SiteChatComponentNew/States/StartChatState.css
|
|
1707
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-3e05ef30")) {
|
|
1708
|
+
const s = document.createElement("style");
|
|
1709
|
+
s.id = "jrapps-style-3e05ef30";
|
|
1710
|
+
s.textContent = ".cw-start-chat-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px 24px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 14px;\n}\n\n.cw-start-chat-state__image {\n width: 80px;\n height: 80px;\n object-fit: contain;\n border-radius: 50%;\n margin-bottom: 4px;\n}\n\n.cw-start-chat-state__title {\n font-size: 20px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-start-chat-state__description {\n font-size: 14px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 260px;\n line-height: 1.6;\n}\n";
|
|
1711
|
+
document.head.appendChild(s);
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
// src/components/SiteChatComponentNew/States/StartChatState.tsx
|
|
1715
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1716
|
+
var StartChatState = ({
|
|
1717
|
+
image,
|
|
1718
|
+
title,
|
|
1719
|
+
description,
|
|
1720
|
+
onStart
|
|
1721
|
+
}) => {
|
|
1722
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
1723
|
+
"div",
|
|
1724
|
+
{
|
|
1725
|
+
className: "cw-start-chat-state",
|
|
1726
|
+
role: "main",
|
|
1727
|
+
"aria-label": "Start a chat",
|
|
1728
|
+
children: [
|
|
1729
|
+
image && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1730
|
+
"img",
|
|
1731
|
+
{
|
|
1732
|
+
src: image,
|
|
1733
|
+
alt: "Support illustration",
|
|
1734
|
+
className: "cw-start-chat-state__image"
|
|
1735
|
+
}
|
|
1736
|
+
),
|
|
1737
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("h2", { className: "cw-start-chat-state__title", children: title }),
|
|
1738
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", { className: "cw-start-chat-state__description", children: description }),
|
|
1739
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Button_default, { onClick: onStart, ariaLabel: "Start chat", children: "Start Chat" })
|
|
1740
|
+
]
|
|
1741
|
+
}
|
|
1742
|
+
);
|
|
1743
|
+
};
|
|
1744
|
+
var StartChatState_default = StartChatState;
|
|
1745
|
+
|
|
1746
|
+
// src/components/SiteChatComponentNew/OfflineForm/OfflineForm.css
|
|
1747
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-d9ff3956")) {
|
|
1748
|
+
const s = document.createElement("style");
|
|
1749
|
+
s.id = "jrapps-style-d9ff3956";
|
|
1750
|
+
s.textContent = `.cw-offline-form {
|
|
1751
|
+
display: flex;
|
|
1752
|
+
flex-direction: column;
|
|
1753
|
+
gap: 14px;
|
|
1754
|
+
}
|
|
1755
|
+
|
|
1756
|
+
.cw-offline-form__title {
|
|
1757
|
+
font-size: 15px;
|
|
1758
|
+
font-weight: 600;
|
|
1759
|
+
color: var(--cw-agent-text);
|
|
1760
|
+
margin: 0 0 4px;
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
/* Field wrapper */
|
|
1764
|
+
.cw-offline-form__field {
|
|
1765
|
+
display: flex;
|
|
1766
|
+
flex-direction: column;
|
|
1767
|
+
gap: 5px;
|
|
1768
|
+
}
|
|
1769
|
+
|
|
1770
|
+
.cw-offline-form__field--checkbox {
|
|
1771
|
+
gap: 4px;
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
/* Label */
|
|
1775
|
+
.cw-offline-form__label {
|
|
1776
|
+
font-size: 13px;
|
|
1777
|
+
font-weight: 500;
|
|
1778
|
+
color: var(--cw-agent-text);
|
|
1779
|
+
}
|
|
1780
|
+
|
|
1781
|
+
.cw-offline-form__required {
|
|
1782
|
+
color: #ef4444;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/* Text input */
|
|
1786
|
+
.cw-offline-form__input {
|
|
1787
|
+
width: 100%;
|
|
1788
|
+
padding: 8px 12px;
|
|
1789
|
+
border: 1px solid var(--cw-input-border);
|
|
1790
|
+
border-radius: var(--cw-button-radius);
|
|
1791
|
+
background-color: var(--cw-input-background);
|
|
1792
|
+
font-family: var(--cw-font-family);
|
|
1793
|
+
font-size: var(--cw-font-size);
|
|
1794
|
+
color: inherit;
|
|
1795
|
+
box-sizing: border-box;
|
|
1796
|
+
transition: border-color 0.15s ease;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
.cw-offline-form__input:focus {
|
|
1800
|
+
outline: none;
|
|
1801
|
+
border-color: var(--cw-primary);
|
|
1802
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
|
|
1803
|
+
}
|
|
1804
|
+
|
|
1805
|
+
.cw-offline-form__input--error {
|
|
1806
|
+
border-color: #ef4444;
|
|
1807
|
+
}
|
|
1808
|
+
|
|
1809
|
+
/* Textarea */
|
|
1810
|
+
.cw-offline-form__textarea {
|
|
1811
|
+
width: 100%;
|
|
1812
|
+
padding: 8px 12px;
|
|
1813
|
+
border: 1px solid var(--cw-input-border);
|
|
1814
|
+
border-radius: var(--cw-button-radius);
|
|
1815
|
+
background-color: var(--cw-input-background);
|
|
1816
|
+
font-family: var(--cw-font-family);
|
|
1817
|
+
font-size: var(--cw-font-size);
|
|
1818
|
+
color: inherit;
|
|
1819
|
+
resize: vertical;
|
|
1820
|
+
box-sizing: border-box;
|
|
1821
|
+
transition: border-color 0.15s ease;
|
|
1822
|
+
}
|
|
1823
|
+
|
|
1824
|
+
.cw-offline-form__textarea:focus {
|
|
1825
|
+
outline: none;
|
|
1826
|
+
border-color: var(--cw-primary);
|
|
1827
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
|
|
1828
|
+
}
|
|
1829
|
+
|
|
1830
|
+
.cw-offline-form__textarea--error {
|
|
1831
|
+
border-color: #ef4444;
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
/* Select */
|
|
1835
|
+
.cw-offline-form__select {
|
|
1836
|
+
width: 100%;
|
|
1837
|
+
padding: 8px 12px;
|
|
1838
|
+
border: 1px solid var(--cw-input-border);
|
|
1839
|
+
border-radius: var(--cw-button-radius);
|
|
1840
|
+
background-color: var(--cw-input-background);
|
|
1841
|
+
font-family: var(--cw-font-family);
|
|
1842
|
+
font-size: var(--cw-font-size);
|
|
1843
|
+
color: inherit;
|
|
1844
|
+
box-sizing: border-box;
|
|
1845
|
+
appearance: none;
|
|
1846
|
+
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
|
|
1847
|
+
background-repeat: no-repeat;
|
|
1848
|
+
background-position: right 12px center;
|
|
1849
|
+
padding-right: 32px;
|
|
1850
|
+
cursor: pointer;
|
|
1851
|
+
transition: border-color 0.15s ease;
|
|
1852
|
+
}
|
|
1853
|
+
|
|
1854
|
+
.cw-offline-form__select:focus {
|
|
1855
|
+
outline: none;
|
|
1856
|
+
border-color: var(--cw-primary);
|
|
1857
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
|
|
1858
|
+
}
|
|
1859
|
+
|
|
1860
|
+
.cw-offline-form__select--error {
|
|
1861
|
+
border-color: #ef4444;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
/* Checkbox */
|
|
1865
|
+
.cw-offline-form__checkbox-label {
|
|
1866
|
+
display: flex;
|
|
1867
|
+
align-items: flex-start;
|
|
1868
|
+
gap: 8px;
|
|
1869
|
+
cursor: pointer;
|
|
1870
|
+
font-size: 13px;
|
|
1871
|
+
color: var(--cw-agent-text);
|
|
1872
|
+
}
|
|
1873
|
+
|
|
1874
|
+
.cw-offline-form__checkbox {
|
|
1875
|
+
width: 16px;
|
|
1876
|
+
height: 16px;
|
|
1877
|
+
accent-color: var(--cw-primary);
|
|
1878
|
+
flex-shrink: 0;
|
|
1879
|
+
margin-top: 1px;
|
|
1880
|
+
cursor: pointer;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
.cw-offline-form__checkbox:focus-visible {
|
|
1884
|
+
outline: 2px solid var(--cw-primary);
|
|
1885
|
+
outline-offset: 2px;
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
.cw-offline-form__checkbox-text {
|
|
1889
|
+
line-height: 1.4;
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
/* Error message */
|
|
1893
|
+
.cw-offline-form__error {
|
|
1894
|
+
font-size: 12px;
|
|
1895
|
+
color: #ef4444;
|
|
1896
|
+
font-weight: 500;
|
|
1897
|
+
}
|
|
1898
|
+
|
|
1899
|
+
/* Actions */
|
|
1900
|
+
.cw-offline-form__actions {
|
|
1901
|
+
margin-top: 4px;
|
|
1902
|
+
}
|
|
1903
|
+
`;
|
|
1904
|
+
document.head.appendChild(s);
|
|
1905
|
+
}
|
|
1906
|
+
|
|
1907
|
+
// src/components/SiteChatComponentNew/OfflineForm/OfflineForm.tsx
|
|
1908
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
1909
|
+
var FieldRenderer = ({
|
|
1910
|
+
field,
|
|
1911
|
+
value,
|
|
1912
|
+
error,
|
|
1913
|
+
onChange
|
|
1914
|
+
}) => {
|
|
1915
|
+
var _a, _b;
|
|
1916
|
+
const hasError = error.length > 0;
|
|
1917
|
+
const fieldId = `cw-offline-field-${field.id}`;
|
|
1918
|
+
const errorId = `${fieldId}-error`;
|
|
1919
|
+
const commonProps = {
|
|
1920
|
+
id: fieldId,
|
|
1921
|
+
className: `cw-offline-form__input${hasError ? " cw-offline-form__input--error" : ""}`,
|
|
1922
|
+
"aria-invalid": hasError,
|
|
1923
|
+
"aria-describedby": hasError ? errorId : void 0,
|
|
1924
|
+
required: field.required
|
|
1925
|
+
};
|
|
1926
|
+
if (field.type === "textarea") {
|
|
1927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "cw-offline-form__field", children: [
|
|
1928
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
|
|
1929
|
+
field.label,
|
|
1930
|
+
field.required && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
|
|
1931
|
+
" ",
|
|
1932
|
+
"*"
|
|
1933
|
+
] })
|
|
1934
|
+
] }),
|
|
1935
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1936
|
+
"textarea",
|
|
1937
|
+
{
|
|
1938
|
+
...commonProps,
|
|
1939
|
+
value: String(value != null ? value : ""),
|
|
1940
|
+
placeholder: field.placeholder,
|
|
1941
|
+
rows: 3,
|
|
1942
|
+
onChange: (e) => onChange(field.id, e.target.value),
|
|
1943
|
+
className: `cw-offline-form__textarea${hasError ? " cw-offline-form__textarea--error" : ""}`
|
|
1944
|
+
}
|
|
1945
|
+
),
|
|
1946
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
|
|
1947
|
+
] });
|
|
1948
|
+
}
|
|
1949
|
+
if (field.type === "select") {
|
|
1950
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "cw-offline-form__field", children: [
|
|
1951
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
|
|
1952
|
+
field.label,
|
|
1953
|
+
field.required && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
|
|
1954
|
+
" ",
|
|
1955
|
+
"*"
|
|
1956
|
+
] })
|
|
1957
|
+
] }),
|
|
1958
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1959
|
+
"select",
|
|
1960
|
+
{
|
|
1961
|
+
...commonProps,
|
|
1962
|
+
value: String(value != null ? value : ""),
|
|
1963
|
+
onChange: (e) => onChange(field.id, e.target.value),
|
|
1964
|
+
className: `cw-offline-form__select${hasError ? " cw-offline-form__select--error" : ""}`,
|
|
1965
|
+
children: [
|
|
1966
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: "", children: (_a = field.placeholder) != null ? _a : `Select ${field.label}` }),
|
|
1967
|
+
(_b = field.options) == null ? void 0 : _b.map((opt) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("option", { value: opt.value, children: opt.label }, opt.value))
|
|
1968
|
+
]
|
|
1969
|
+
}
|
|
1970
|
+
),
|
|
1971
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
|
|
1972
|
+
] });
|
|
1973
|
+
}
|
|
1974
|
+
if (field.type === "checkbox") {
|
|
1975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "cw-offline-form__field cw-offline-form__field--checkbox", children: [
|
|
1976
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { className: "cw-offline-form__checkbox-label", htmlFor: fieldId, children: [
|
|
1977
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1978
|
+
"input",
|
|
1979
|
+
{
|
|
1980
|
+
type: "checkbox",
|
|
1981
|
+
id: fieldId,
|
|
1982
|
+
checked: Boolean(value),
|
|
1983
|
+
onChange: (e) => onChange(field.id, e.target.checked),
|
|
1984
|
+
className: "cw-offline-form__checkbox",
|
|
1985
|
+
"aria-invalid": hasError,
|
|
1986
|
+
"aria-describedby": hasError ? errorId : void 0,
|
|
1987
|
+
required: field.required
|
|
1988
|
+
}
|
|
1989
|
+
),
|
|
1990
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "cw-offline-form__checkbox-text", children: [
|
|
1991
|
+
field.label,
|
|
1992
|
+
field.required && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
|
|
1993
|
+
" ",
|
|
1994
|
+
"*"
|
|
1995
|
+
] })
|
|
1996
|
+
] })
|
|
1997
|
+
] }),
|
|
1998
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
|
|
1999
|
+
] });
|
|
2000
|
+
}
|
|
2001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "cw-offline-form__field", children: [
|
|
2002
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
|
|
2003
|
+
field.label,
|
|
2004
|
+
field.required && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
|
|
2005
|
+
" ",
|
|
2006
|
+
"*"
|
|
2007
|
+
] })
|
|
2008
|
+
] }),
|
|
2009
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2010
|
+
"input",
|
|
2011
|
+
{
|
|
2012
|
+
...commonProps,
|
|
2013
|
+
type: field.type,
|
|
2014
|
+
value: String(value != null ? value : ""),
|
|
2015
|
+
placeholder: field.placeholder,
|
|
2016
|
+
onChange: (e) => onChange(field.id, e.target.value)
|
|
2017
|
+
}
|
|
2018
|
+
),
|
|
2019
|
+
hasError && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
|
|
2020
|
+
] });
|
|
2021
|
+
};
|
|
2022
|
+
var OfflineForm = ({ schema, onSubmit }) => {
|
|
2023
|
+
const { values, errors, setValue, handleSubmit } = useOfflineForm(schema);
|
|
2024
|
+
const onFormSubmit = (e) => {
|
|
2025
|
+
e.preventDefault();
|
|
2026
|
+
handleSubmit(onSubmit);
|
|
2027
|
+
};
|
|
2028
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2029
|
+
"form",
|
|
2030
|
+
{
|
|
2031
|
+
className: "cw-offline-form",
|
|
2032
|
+
onSubmit: onFormSubmit,
|
|
2033
|
+
"aria-label": schema.title,
|
|
2034
|
+
noValidate: true,
|
|
2035
|
+
children: [
|
|
2036
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("h3", { className: "cw-offline-form__title", children: schema.title }),
|
|
2037
|
+
schema.fields.map((field) => {
|
|
2038
|
+
var _a;
|
|
2039
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2040
|
+
FieldRenderer,
|
|
2041
|
+
{
|
|
2042
|
+
field,
|
|
2043
|
+
value: values[field.id],
|
|
2044
|
+
error: (_a = errors[field.id]) != null ? _a : "",
|
|
2045
|
+
onChange: setValue
|
|
2046
|
+
},
|
|
2047
|
+
field.id
|
|
2048
|
+
);
|
|
2049
|
+
}),
|
|
2050
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "cw-offline-form__actions", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Button_default, { type: "submit", fullWidth: true, children: schema.submitButtonText }) })
|
|
2051
|
+
]
|
|
2052
|
+
}
|
|
2053
|
+
);
|
|
2054
|
+
};
|
|
2055
|
+
var OfflineForm_default = OfflineForm;
|
|
2056
|
+
|
|
2057
|
+
// src/components/SiteChatComponentNew/States/OfflineState.css
|
|
2058
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-8b15ae78")) {
|
|
2059
|
+
const s = document.createElement("style");
|
|
2060
|
+
s.id = "jrapps-style-8b15ae78";
|
|
2061
|
+
s.textContent = ".cw-offline-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n background-color: var(--cw-background);\n overflow-y: auto;\n}\n\n.cw-offline-state__header {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n padding: 28px 24px 16px;\n gap: 8px;\n}\n\n.cw-offline-state__icon {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n color: var(--cw-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n margin-bottom: 4px;\n}\n\n.cw-offline-state__title {\n font-size: 17px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-offline-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n line-height: 1.6;\n max-width: 280px;\n}\n\n.cw-offline-state__form-wrapper {\n padding: 0 16px 16px;\n}\n";
|
|
2062
|
+
document.head.appendChild(s);
|
|
2063
|
+
}
|
|
2064
|
+
|
|
2065
|
+
// src/components/SiteChatComponentNew/States/OfflineState.tsx
|
|
2066
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2067
|
+
var OfflineState = ({ form, onSubmit }) => {
|
|
2068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2069
|
+
"div",
|
|
2070
|
+
{
|
|
2071
|
+
className: "cw-offline-state",
|
|
2072
|
+
role: "main",
|
|
2073
|
+
"aria-label": "Business is offline",
|
|
2074
|
+
children: [
|
|
2075
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "cw-offline-state__header", children: [
|
|
2076
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "cw-offline-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2077
|
+
"svg",
|
|
2078
|
+
{
|
|
2079
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2080
|
+
width: "32",
|
|
2081
|
+
height: "32",
|
|
2082
|
+
viewBox: "0 0 24 24",
|
|
2083
|
+
fill: "none",
|
|
2084
|
+
stroke: "currentColor",
|
|
2085
|
+
strokeWidth: "2",
|
|
2086
|
+
strokeLinecap: "round",
|
|
2087
|
+
strokeLinejoin: "round",
|
|
2088
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("path", { d: "M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" })
|
|
2089
|
+
}
|
|
2090
|
+
) }),
|
|
2091
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { className: "cw-offline-state__title", children: "We're currently offline" }),
|
|
2092
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "cw-offline-state__subtitle", children: "Please leave us a message and we'll get back to you as soon as possible." })
|
|
2093
|
+
] }),
|
|
2094
|
+
form && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "cw-offline-state__form-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(OfflineForm_default, { schema: form, onSubmit }) })
|
|
2095
|
+
]
|
|
2096
|
+
}
|
|
2097
|
+
);
|
|
2098
|
+
};
|
|
2099
|
+
var OfflineState_default = OfflineState;
|
|
2100
|
+
|
|
2101
|
+
// src/components/SiteChatComponentNew/States/ChatEndedState.css
|
|
2102
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-59a49fdf")) {
|
|
2103
|
+
const s = document.createElement("style");
|
|
2104
|
+
s.id = "jrapps-style-59a49fdf";
|
|
2105
|
+
s.textContent = ".cw-chat-ended-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px 24px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 12px;\n}\n\n.cw-chat-ended-state__icon {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n color: var(--cw-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.cw-chat-ended-state__title {\n font-size: 17px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-chat-ended-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 240px;\n line-height: 1.6;\n}\n";
|
|
2106
|
+
document.head.appendChild(s);
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
// src/components/SiteChatComponentNew/States/ChatEndedState.tsx
|
|
2110
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2111
|
+
var ChatEndedState = () => {
|
|
2112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
2113
|
+
"div",
|
|
2114
|
+
{
|
|
2115
|
+
className: "cw-chat-ended-state",
|
|
2116
|
+
role: "status",
|
|
2117
|
+
"aria-label": "Chat has ended",
|
|
2118
|
+
children: [
|
|
2119
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "cw-chat-ended-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
2120
|
+
"svg",
|
|
2121
|
+
{
|
|
2122
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2123
|
+
width: "32",
|
|
2124
|
+
height: "32",
|
|
2125
|
+
viewBox: "0 0 24 24",
|
|
2126
|
+
fill: "none",
|
|
2127
|
+
stroke: "currentColor",
|
|
2128
|
+
strokeWidth: "2",
|
|
2129
|
+
strokeLinecap: "round",
|
|
2130
|
+
strokeLinejoin: "round",
|
|
2131
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("polyline", { points: "20 6 9 17 4 12" })
|
|
2132
|
+
}
|
|
2133
|
+
) }),
|
|
2134
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "cw-chat-ended-state__title", children: "Chat Ended" }),
|
|
2135
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "cw-chat-ended-state__subtitle", children: "Your chat session has ended. Thank you for reaching out!" })
|
|
2136
|
+
]
|
|
2137
|
+
}
|
|
2138
|
+
);
|
|
2139
|
+
};
|
|
2140
|
+
var ChatEndedState_default = ChatEndedState;
|
|
2141
|
+
|
|
2142
|
+
// src/components/SiteChatComponentNew/SiteChatComponentNew.css
|
|
2143
|
+
if (typeof document !== "undefined" && !document.getElementById("jrapps-style-871af89c")) {
|
|
2144
|
+
const s = document.createElement("style");
|
|
2145
|
+
s.id = "jrapps-style-871af89c";
|
|
2146
|
+
s.textContent = "/* \u2500\u2500\u2500 Root container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n * Fixed to bottom-right by default so it works out-of-the-box.\n * Override with your own positioning class if embedding differently.\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.cw-root {\n position: fixed;\n bottom: max(24px, env(safe-area-inset-bottom));\n right: max(24px, env(safe-area-inset-right));\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 12px;\n z-index: 9999;\n /* Scope CSS vars and stacking context */\n isolation: isolate;\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n}\n\n/* \u2500\u2500\u2500 Widget Panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.cw-widget {\n display: flex;\n flex-direction: column;\n width: var(--cw-width);\n height: var(--cw-height);\n /* Clamp so it never overflows the viewport on small screens */\n max-width: calc(100vw - 48px);\n max-height: calc(100dvh - 96px);\n background-color: var(--cw-background);\n border-radius: var(--cw-border-radius);\n box-shadow: var(--cw-shadow);\n overflow: hidden;\n /* Entry animation */\n animation: cw-panel-in 0.22s ease;\n transform-origin: bottom right;\n}\n\n@keyframes cw-panel-in {\n from {\n opacity: 0;\n transform: scale(0.92) translateY(10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n.cw-widget__body {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n}\n\n/* \u2500\u2500\u2500 Launcher Button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.cw-launcher {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n background-color: var(--cw-primary);\n color: #ffffff;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);\n flex-shrink: 0;\n transition: transform 0.15s ease, box-shadow 0.15s ease;\n}\n\n.cw-launcher:hover {\n transform: scale(1.07);\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.26);\n}\n\n.cw-launcher:focus-visible {\n outline: 3px solid var(--cw-primary);\n outline-offset: 3px;\n}\n\n.cw-launcher:active {\n transform: scale(0.96);\n}\n\n/* \u2500\u2500\u2500 Tablet (481px \u2013 768px): panel floats, slightly narrower margin \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n@media (min-width: 481px) and (max-width: 768px) {\n .cw-root {\n bottom: max(16px, env(safe-area-inset-bottom));\n right: max(16px, env(safe-area-inset-right));\n }\n\n .cw-widget {\n max-width: calc(100vw - 32px);\n max-height: calc(100dvh - 80px);\n }\n}\n\n/* \u2500\u2500\u2500 Mobile (\u2264 480px): full-screen panel, launcher stays fixed \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n@media (max-width: 480px) {\n .cw-root {\n bottom: 0;\n right: 0;\n gap: 0;\n }\n\n .cw-root > .cw-launcher {\n position: fixed;\n bottom: max(20px, env(safe-area-inset-bottom));\n right: max(20px, env(safe-area-inset-right));\n }\n\n .cw-widget {\n width: 100vw;\n max-width: 100vw;\n height: 100dvh;\n max-height: 100dvh;\n border-radius: 0;\n transform-origin: bottom center;\n }\n}\n";
|
|
2147
|
+
document.head.appendChild(s);
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2150
|
+
// src/components/SiteChatComponentNew/SiteChatComponentNew.tsx
|
|
2151
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2152
|
+
var SiteChatComponentNew = import_react12.default.forwardRef(({
|
|
2153
|
+
title,
|
|
2154
|
+
subtitle,
|
|
2155
|
+
image,
|
|
2156
|
+
theme,
|
|
2157
|
+
messages,
|
|
2158
|
+
offlineForm,
|
|
2159
|
+
defaultOpen = false,
|
|
2160
|
+
loading = false,
|
|
2161
|
+
chatEnded = false,
|
|
2162
|
+
onSend,
|
|
2163
|
+
onAttachment,
|
|
2164
|
+
onOfflineSubmit,
|
|
2165
|
+
onClose
|
|
2166
|
+
}, ref) => {
|
|
2167
|
+
const { open, openWidget, closeWidget } = useSiteChatComponentNew(defaultOpen);
|
|
2168
|
+
const themeVars = buildThemeVars(theme);
|
|
2169
|
+
const handleClose = () => {
|
|
2170
|
+
closeWidget();
|
|
2171
|
+
onClose == null ? void 0 : onClose();
|
|
2172
|
+
};
|
|
2173
|
+
const renderBody = () => {
|
|
2174
|
+
if (loading) {
|
|
2175
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(LoadingState_default, {});
|
|
2176
|
+
}
|
|
2177
|
+
if (offlineForm) {
|
|
2178
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(OfflineState_default, { form: offlineForm, onSubmit: onOfflineSubmit });
|
|
2179
|
+
}
|
|
2180
|
+
if (messages.length === 0) {
|
|
2181
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2182
|
+
StartChatState_default,
|
|
2183
|
+
{
|
|
2184
|
+
image,
|
|
2185
|
+
title,
|
|
2186
|
+
description: subtitle,
|
|
2187
|
+
onStart: () => onSend("__start_chat__")
|
|
2188
|
+
}
|
|
2189
|
+
);
|
|
2190
|
+
}
|
|
2191
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
2192
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(MessageList_default, { messages }),
|
|
2193
|
+
chatEnded ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(ChatEndedState_default, {}) : /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Footer_default, { onSend, onAttachment })
|
|
2194
|
+
] });
|
|
2195
|
+
};
|
|
2196
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { ref, className: "cw-root", style: themeVars, children: [
|
|
2197
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(
|
|
2198
|
+
"div",
|
|
2199
|
+
{
|
|
2200
|
+
className: "cw-widget",
|
|
2201
|
+
role: "dialog",
|
|
2202
|
+
"aria-modal": "true",
|
|
2203
|
+
"aria-label": `${title} chat widget`,
|
|
2204
|
+
children: [
|
|
2205
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2206
|
+
Header_default,
|
|
2207
|
+
{
|
|
2208
|
+
image,
|
|
2209
|
+
title,
|
|
2210
|
+
subtitle,
|
|
2211
|
+
onClose: handleClose
|
|
2212
|
+
}
|
|
2213
|
+
),
|
|
2214
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "cw-widget__body", children: renderBody() })
|
|
2215
|
+
]
|
|
2216
|
+
}
|
|
2217
|
+
),
|
|
2218
|
+
!open && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2219
|
+
"button",
|
|
2220
|
+
{
|
|
2221
|
+
className: "cw-launcher",
|
|
2222
|
+
onClick: openWidget,
|
|
2223
|
+
"aria-label": "Open chat",
|
|
2224
|
+
"aria-haspopup": "dialog",
|
|
2225
|
+
type: "button",
|
|
2226
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2227
|
+
"svg",
|
|
2228
|
+
{
|
|
2229
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
2230
|
+
width: "26",
|
|
2231
|
+
height: "26",
|
|
2232
|
+
viewBox: "0 0 24 24",
|
|
2233
|
+
fill: "currentColor",
|
|
2234
|
+
"aria-hidden": "true",
|
|
2235
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z" })
|
|
2236
|
+
}
|
|
2237
|
+
)
|
|
2238
|
+
}
|
|
2239
|
+
)
|
|
2240
|
+
] });
|
|
2241
|
+
});
|
|
2242
|
+
SiteChatComponentNew.displayName = "SiteChatComponentNew";
|
|
998
2243
|
//# sourceMappingURL=index.js.map
|