@axos-web-dev/shared-components 1.0.77-patch.38 → 1.0.77-patch.39
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/ATMLocator/ATMLocator.js +1 -8
- package/dist/Auth/ErrorAlert.js +1 -8
- package/dist/Avatar/Avatar.module.js +7 -7
- package/dist/Blockquote/Blockquote.module.js +3 -3
- package/dist/Button/Button.js +1 -8
- package/dist/Calculators/BuyDownCalculator/index.js +1 -1
- package/dist/Calculators/Calculator.js +2 -9
- package/dist/Calculators/SummitApyCalculator/index.js +15 -6
- package/dist/Carousel/index.js +1 -8
- package/dist/Chevron/index.js +1 -8
- package/dist/Comparison/Comparison.js +1 -8
- package/dist/ExecutiveBio/ExecutiveBio.js +1 -8
- package/dist/FaqAccordion/index.js +1 -8
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +1 -8
- package/dist/Forms/ApplyNow.js +1 -8
- package/dist/Forms/ContactUsBusiness.js +1 -8
- package/dist/Forms/ContactUsBusinessNameEmail.js +1 -8
- package/dist/Forms/ContactUsNMLSId.js +1 -8
- package/dist/Forms/CraPublicFile.js +1 -8
- package/dist/Forms/EmailOnly.js +1 -8
- package/dist/Forms/MortgageRate/MortgageRateForm.js +1 -8
- package/dist/Forms/MortgageRate/MortgageRateWatch.js +1 -8
- package/dist/Forms/MortgageWarehouseLending.js +1 -8
- package/dist/Forms/SuccesForm.js +2 -9
- package/dist/Hyperlink/index.js +1 -8
- package/dist/ImageLink/ImageLink.js +1 -8
- package/dist/ImageLink/ImageLinkSet.js +1 -8
- package/dist/ImageLink/index.js +1 -8
- package/dist/Insight/Featured/CategorySelector.js +1 -8
- package/dist/Insight/Featured/Featured.js +1 -8
- package/dist/Insight/Featured/Header.js +1 -8
- package/dist/Modal/Modal.js +1 -8
- package/dist/NavigationMenu/AxosALTS/NavData.js +1 -8
- package/dist/NavigationMenu/AxosALTS/index.js +1 -8
- package/dist/NavigationMenu/AxosAdvisor/NavBar.module.js +52 -52
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.module.js +53 -53
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +16 -16
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +1 -8
- package/dist/NavigationMenu/AxosBank/NavBar.module.js +39 -39
- package/dist/NavigationMenu/AxosBank/NavData.js +1 -8
- package/dist/NavigationMenu/AxosBank/SubNavBar.js +1 -8
- package/dist/NavigationMenu/AxosBank/index.js +1 -8
- package/dist/NavigationMenu/AxosClearing/NavBar.module.js +37 -37
- package/dist/NavigationMenu/AxosFiduciary/NavBar.module.js +41 -41
- package/dist/NavigationMenu/LaVictoire/NavData.js +1 -8
- package/dist/NavigationMenu/LaVictoire/index.js +1 -8
- package/dist/SetContainer/SetContainer.js +1 -8
- package/dist/SocialMediaBar/iconsRepository.js +1 -8
- package/dist/Table/Table.d.ts +1 -1
- package/dist/VideoTile/VideoTile.js +1 -8
- package/dist/VideoWrapper/index.js +1 -8
- package/dist/WalnutIframe/wrapper.module.js +3 -3
- package/dist/assets/Avatar/Avatar.css.css +59 -59
- package/dist/assets/Blockquote/Blockquote.css.css +68 -68
- package/dist/assets/NavigationMenu/AxosAdvisor/NavBar.css.css +597 -597
- package/dist/assets/NavigationMenu/AxosAdvisorServices/NavBar.css.css +618 -618
- package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css.css +191 -191
- package/dist/assets/NavigationMenu/AxosBank/NavBar.css.css +473 -473
- package/dist/assets/NavigationMenu/AxosClearing/NavBar.css.css +458 -458
- package/dist/assets/NavigationMenu/AxosFiduciary/NavBar.css.css +426 -426
- package/dist/assets/WalnutIframe/wrapper.css.css +48 -48
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -35
- package/dist/utils/emailValidation.d.ts +1 -0
- package/dist/utils/emailValidation.js +31 -0
- package/dist/utils/nmlsValidation.d.ts +1 -0
- package/dist/utils/nmlsValidation.js +31 -0
- package/package.json +133 -135
- package/dist/Chatbot/Bubble.css.d.ts +0 -2
- package/dist/Chatbot/Bubble.css.js +0 -8
- package/dist/Chatbot/Bubble.d.ts +0 -5
- package/dist/Chatbot/Bubble.js +0 -103
- package/dist/Chatbot/Chat.d.ts +0 -1
- package/dist/Chatbot/Chat.js +0 -165
- package/dist/Chatbot/ChatWindow.css.d.ts +0 -18
- package/dist/Chatbot/ChatWindow.css.js +0 -39
- package/dist/Chatbot/ChatWindow.d.ts +0 -26
- package/dist/Chatbot/ChatWindow.js +0 -446
- package/dist/Chatbot/Chatbot.css.d.ts +0 -2
- package/dist/Chatbot/Chatbot.css.js +0 -6
- package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +0 -1
- package/dist/Chatbot/Chatbot.d.ts +0 -10
- package/dist/Chatbot/Chatbot.js +0 -221
- package/dist/Chatbot/EllipsisAnimation.d.ts +0 -2
- package/dist/Chatbot/EllipsisAnimation.js +0 -85
- package/dist/Chatbot/EllipsisIcon.d.ts +0 -4
- package/dist/Chatbot/EllipsisIcon.js +0 -19
- package/dist/Chatbot/authenticate.d.ts +0 -3
- package/dist/Chatbot/authenticate.js +0 -16
- package/dist/Chatbot/index.d.ts +0 -8
- package/dist/Chatbot/index.js +0 -38
- package/dist/Chatbot/store/chat.d.ts +0 -10
- package/dist/Chatbot/store/chat.js +0 -18
- package/dist/Chatbot/store/messages.d.ts +0 -15
- package/dist/Chatbot/store/messages.js +0 -13
- package/dist/Chatbot/useHeadlessChat.d.ts +0 -27
- package/dist/Chatbot/useHeadlessChat.js +0 -240
- package/dist/assets/Chatbot/Bubble.css +0 -51
- package/dist/assets/Chatbot/ChatWindow.css +0 -213
|
@@ -1,446 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import React, { useRef, useEffect, Fragment as Fragment$1 } from "react";
|
|
5
|
-
import ReactMarkdown from "react-markdown";
|
|
6
|
-
import { useNetworkState, useMount } from "react-use";
|
|
7
|
-
import remarkGfm from "remark-gfm";
|
|
8
|
-
import { windowBarStyle, chat_title, chatbotMenuItem, chatbotMenu, chatFinishDialog, endChatButtonStyle, button_reset, arrowFill, chatNetworkStatus, notificationStyle, messageStyle, inline_button_wrapper, inline_button, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
|
|
9
|
-
import EllipsisLoader from "./EllipsisAnimation.js";
|
|
10
|
-
import { EllipsisIcon } from "./EllipsisIcon.js";
|
|
11
|
-
import { useOpenChat } from "./store/chat.js";
|
|
12
|
-
const ChatWindow = ({
|
|
13
|
-
messages,
|
|
14
|
-
status = "connected",
|
|
15
|
-
onSend,
|
|
16
|
-
inputDisabled = false,
|
|
17
|
-
onClose,
|
|
18
|
-
endChat = () => {
|
|
19
|
-
console.log("End chat");
|
|
20
|
-
},
|
|
21
|
-
showReconnect = false,
|
|
22
|
-
virtualAgent,
|
|
23
|
-
showAvatar = false
|
|
24
|
-
}) => {
|
|
25
|
-
const [mounted, setMounted] = React.useState(false);
|
|
26
|
-
const [menuOpen, setMenuOpen] = React.useState(false);
|
|
27
|
-
const [showEndChatDialog, setShowEndChatDialog] = React.useState(false);
|
|
28
|
-
const state = useNetworkState();
|
|
29
|
-
const [input, setInput] = React.useState("");
|
|
30
|
-
const messagesEndRef = useRef(null);
|
|
31
|
-
const isOpen = useOpenChat((state2) => state2.isOpen);
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
34
|
-
}, [messages]);
|
|
35
|
-
const handleSend = (e) => {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
if (input.trim()) {
|
|
38
|
-
onSend(input);
|
|
39
|
-
setInput("");
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
useMount(() => {
|
|
43
|
-
setMounted(true);
|
|
44
|
-
});
|
|
45
|
-
const project = process.env.CCAI_PROJECT_ID;
|
|
46
|
-
const isAxos = project === "axos";
|
|
47
|
-
const endUserBg = isAxos ? "#14263d" : "#323339";
|
|
48
|
-
const chatbotBg = isAxos ? "#E9F8FF" : "#EAE8E8";
|
|
49
|
-
const escalationDeflected = messages?.filter(
|
|
50
|
-
(item) => item.type == "noti" && item.event == "escalationDeflected"
|
|
51
|
-
).length > 0;
|
|
52
|
-
return /* @__PURE__ */ jsxs("div", { className: clsx(windowStyle, isOpen && windowOpenStyle), children: [
|
|
53
|
-
/* @__PURE__ */ jsxs("div", { className: windowBarStyle, children: [
|
|
54
|
-
/* @__PURE__ */ jsxs("div", { className: "flex middle", style: { paddingBlock: "6px" }, children: [
|
|
55
|
-
/* @__PURE__ */ jsx(
|
|
56
|
-
"img",
|
|
57
|
-
{
|
|
58
|
-
src: "https://www.axos.com/images/2xmVfQm5l0HWOKjgxQO1Iw/axb-assistant.svg",
|
|
59
|
-
style: { marginRight: 12 },
|
|
60
|
-
height: 18,
|
|
61
|
-
width: 18
|
|
62
|
-
}
|
|
63
|
-
),
|
|
64
|
-
/* @__PURE__ */ jsx("h2", { className: chat_title, children: "Evo Virtual Assistant" })
|
|
65
|
-
] }),
|
|
66
|
-
/* @__PURE__ */ jsx(
|
|
67
|
-
"button",
|
|
68
|
-
{
|
|
69
|
-
onClick: () => {
|
|
70
|
-
setMenuOpen(!menuOpen);
|
|
71
|
-
},
|
|
72
|
-
style: {
|
|
73
|
-
border: "none",
|
|
74
|
-
background: "transparent",
|
|
75
|
-
marginLeft: "auto",
|
|
76
|
-
cursor: "pointer",
|
|
77
|
-
padding: 0,
|
|
78
|
-
display: "flex",
|
|
79
|
-
alignContent: "center"
|
|
80
|
-
},
|
|
81
|
-
children: /* @__PURE__ */ jsx(EllipsisIcon, { color: "#fff" })
|
|
82
|
-
}
|
|
83
|
-
),
|
|
84
|
-
menuOpen && /* @__PURE__ */ jsx("ul", { className: clsx(chatbotMenu), children: /* @__PURE__ */ jsx("li", { className: chatbotMenuItem, children: /* @__PURE__ */ jsx(
|
|
85
|
-
"button",
|
|
86
|
-
{
|
|
87
|
-
type: "button",
|
|
88
|
-
onClick: () => {
|
|
89
|
-
setShowEndChatDialog(true);
|
|
90
|
-
setMenuOpen(false);
|
|
91
|
-
},
|
|
92
|
-
style: { width: "100%" },
|
|
93
|
-
children: "Finish chat"
|
|
94
|
-
}
|
|
95
|
-
) }) }),
|
|
96
|
-
showEndChatDialog && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
|
-
/* @__PURE__ */ jsx(
|
|
98
|
-
"div",
|
|
99
|
-
{
|
|
100
|
-
style: {
|
|
101
|
-
background: "#00000080",
|
|
102
|
-
position: "fixed",
|
|
103
|
-
top: 0,
|
|
104
|
-
left: 0,
|
|
105
|
-
right: 0,
|
|
106
|
-
bottom: 0,
|
|
107
|
-
zIndex: 999,
|
|
108
|
-
opacity: 0.75
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
),
|
|
112
|
-
/* @__PURE__ */ jsx(
|
|
113
|
-
"dialog",
|
|
114
|
-
{
|
|
115
|
-
open: showEndChatDialog,
|
|
116
|
-
style: {
|
|
117
|
-
padding: "1rem",
|
|
118
|
-
borderRadius: 8,
|
|
119
|
-
background: "#fff",
|
|
120
|
-
color: "#000",
|
|
121
|
-
border: `1px solid ${endUserBg}`,
|
|
122
|
-
outline: "none",
|
|
123
|
-
maxWidth: "90%",
|
|
124
|
-
top: "25%",
|
|
125
|
-
marginInline: "auto",
|
|
126
|
-
zIndex: 1e3
|
|
127
|
-
},
|
|
128
|
-
children: /* @__PURE__ */ jsxs("form", { method: "dialog", className: chatFinishDialog, children: [
|
|
129
|
-
/* @__PURE__ */ jsx("p", { children: "Are you sure you want to end this chat?" }),
|
|
130
|
-
/* @__PURE__ */ jsxs(
|
|
131
|
-
"div",
|
|
132
|
-
{
|
|
133
|
-
style: { display: "flex", gap: "1rem", marginTop: "1rem" },
|
|
134
|
-
children: [
|
|
135
|
-
/* @__PURE__ */ jsx(
|
|
136
|
-
"button",
|
|
137
|
-
{
|
|
138
|
-
className: endChatButtonStyle,
|
|
139
|
-
type: "submit",
|
|
140
|
-
onClick: () => {
|
|
141
|
-
endChat();
|
|
142
|
-
setShowEndChatDialog(false);
|
|
143
|
-
},
|
|
144
|
-
children: "Yes"
|
|
145
|
-
}
|
|
146
|
-
),
|
|
147
|
-
/* @__PURE__ */ jsx(
|
|
148
|
-
"button",
|
|
149
|
-
{
|
|
150
|
-
className: endChatButtonStyle,
|
|
151
|
-
type: "button",
|
|
152
|
-
onClick: () => {
|
|
153
|
-
setShowEndChatDialog(false);
|
|
154
|
-
},
|
|
155
|
-
children: "No"
|
|
156
|
-
}
|
|
157
|
-
)
|
|
158
|
-
]
|
|
159
|
-
}
|
|
160
|
-
)
|
|
161
|
-
] })
|
|
162
|
-
}
|
|
163
|
-
)
|
|
164
|
-
] }),
|
|
165
|
-
onClose && /* @__PURE__ */ jsx(
|
|
166
|
-
"button",
|
|
167
|
-
{
|
|
168
|
-
onClick: onClose,
|
|
169
|
-
className: button_reset,
|
|
170
|
-
"aria-label": "Close chat",
|
|
171
|
-
title: "Close",
|
|
172
|
-
children: /* @__PURE__ */ jsx(
|
|
173
|
-
"svg",
|
|
174
|
-
{
|
|
175
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
176
|
-
width: "24",
|
|
177
|
-
height: "24",
|
|
178
|
-
viewBox: "0 0 24 24",
|
|
179
|
-
fill: "none",
|
|
180
|
-
children: /* @__PURE__ */ jsx(
|
|
181
|
-
"path",
|
|
182
|
-
{
|
|
183
|
-
className: arrowFill,
|
|
184
|
-
d: "M2.46875 7.76574L11.9991 17.2961L21.5294 7.76574L20.4687 6.70508L11.9991 15.1749L3.52941 6.70508L2.46875 7.76574Z",
|
|
185
|
-
fill: "#98DDFF"
|
|
186
|
-
}
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
)
|
|
190
|
-
}
|
|
191
|
-
)
|
|
192
|
-
] }),
|
|
193
|
-
mounted && !state.online ? /* @__PURE__ */ jsx("div", { className: clsx(chatNetworkStatus), children: /* @__PURE__ */ jsxs(
|
|
194
|
-
"div",
|
|
195
|
-
{
|
|
196
|
-
style: {
|
|
197
|
-
color: "#d32f2f",
|
|
198
|
-
textAlign: "center",
|
|
199
|
-
padding: "8px 0",
|
|
200
|
-
fontWeight: 500
|
|
201
|
-
},
|
|
202
|
-
children: [
|
|
203
|
-
/* @__PURE__ */ jsx(
|
|
204
|
-
"span",
|
|
205
|
-
{
|
|
206
|
-
role: "img",
|
|
207
|
-
"aria-label": "disconnected",
|
|
208
|
-
style: { marginRight: 6 },
|
|
209
|
-
children: "⚠️"
|
|
210
|
-
}
|
|
211
|
-
),
|
|
212
|
-
"You are currently disconnected. Please check your connection."
|
|
213
|
-
]
|
|
214
|
-
}
|
|
215
|
-
) }) : null,
|
|
216
|
-
/* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
|
|
217
|
-
(status === "idle" || messages.length == 0) && /* @__PURE__ */ jsx(
|
|
218
|
-
"div",
|
|
219
|
-
{
|
|
220
|
-
className: clsx(),
|
|
221
|
-
style: {
|
|
222
|
-
textAlign: "left",
|
|
223
|
-
alignSelf: "flex-start",
|
|
224
|
-
background: "#eee",
|
|
225
|
-
color: "#1e3860",
|
|
226
|
-
borderRadius: 16,
|
|
227
|
-
padding: "8px 8px",
|
|
228
|
-
maxWidth: "80%",
|
|
229
|
-
marginBottom: 2
|
|
230
|
-
},
|
|
231
|
-
children: /* @__PURE__ */ jsx(
|
|
232
|
-
"div",
|
|
233
|
-
{
|
|
234
|
-
style: {
|
|
235
|
-
fontSize: 13,
|
|
236
|
-
display: "flex",
|
|
237
|
-
flexDirection: "column",
|
|
238
|
-
gap: 4
|
|
239
|
-
},
|
|
240
|
-
children: /* @__PURE__ */ jsx(EllipsisLoader, {})
|
|
241
|
-
}
|
|
242
|
-
)
|
|
243
|
-
}
|
|
244
|
-
),
|
|
245
|
-
messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
246
|
-
msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationStarted" && /* @__PURE__ */ jsx("div", { className: notificationStyle, children: "We are connecting you with a human agent..." }, msg.$index),
|
|
247
|
-
msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
|
|
248
|
-
/* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
|
|
249
|
-
" just left the conversation."
|
|
250
|
-
] }, msg.$index),
|
|
251
|
-
msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationAccepted" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
|
|
252
|
-
"You are now connected with a",
|
|
253
|
-
" ",
|
|
254
|
-
msg.to_agent ? /* @__PURE__ */ jsx("strong", { children: msg?.to_agent?.name }) : "an agent"
|
|
255
|
-
] }, msg.$index),
|
|
256
|
-
msg.type == "noti" && msg.$userType == "virtual_agent" && msg.event == "escalationDeflected" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
257
|
-
/* @__PURE__ */ jsxs(
|
|
258
|
-
"div",
|
|
259
|
-
{
|
|
260
|
-
className: notificationStyle,
|
|
261
|
-
style: { fontSize: 12 },
|
|
262
|
-
children: [
|
|
263
|
-
"Our chat team is available weekdays, 8am-5pm, except federal bank holidays. For immediate assistance you can reach out to us at ",
|
|
264
|
-
/* @__PURE__ */ jsx("a", { href: "tel:1-888-502-2967", children: "1-888-502-2967" }),
|
|
265
|
-
"."
|
|
266
|
-
]
|
|
267
|
-
},
|
|
268
|
-
msg.$index
|
|
269
|
-
),
|
|
270
|
-
/* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
|
|
271
|
-
] }),
|
|
272
|
-
["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsxs(
|
|
273
|
-
"div",
|
|
274
|
-
{
|
|
275
|
-
className: messageStyle,
|
|
276
|
-
style: {
|
|
277
|
-
textAlign: msg.$userType == "end_user" ? "right" : "left",
|
|
278
|
-
alignSelf: msg.$userType == "end_user" ? "flex-end" : "flex-start",
|
|
279
|
-
background: msg.$userType == "end_user" ? endUserBg : chatbotBg,
|
|
280
|
-
color: msg.$userType == "end_user" ? "#fff" : "#1F1F1F",
|
|
281
|
-
boxShadow: msg.$userType == "end_user" ? "0 1px 4px #b3e0ff55" : void 0
|
|
282
|
-
},
|
|
283
|
-
children: [
|
|
284
|
-
/* @__PURE__ */ jsxs(
|
|
285
|
-
"div",
|
|
286
|
-
{
|
|
287
|
-
style: {
|
|
288
|
-
fontSize: 13,
|
|
289
|
-
display: "flex",
|
|
290
|
-
flexDirection: "column",
|
|
291
|
-
gap: 4
|
|
292
|
-
},
|
|
293
|
-
children: [
|
|
294
|
-
msg.$userType == "virtual_agent" && /* @__PURE__ */ jsxs(
|
|
295
|
-
"div",
|
|
296
|
-
{
|
|
297
|
-
style: {
|
|
298
|
-
display: "flex",
|
|
299
|
-
// justifyContent: "center",
|
|
300
|
-
alignItems: "center",
|
|
301
|
-
gap: "8px"
|
|
302
|
-
},
|
|
303
|
-
children: [
|
|
304
|
-
showAvatar && /* @__PURE__ */ jsx(
|
|
305
|
-
"img",
|
|
306
|
-
{
|
|
307
|
-
width: 24,
|
|
308
|
-
height: 24,
|
|
309
|
-
src: virtualAgent?.avatar_url,
|
|
310
|
-
alt: "agent avatar"
|
|
311
|
-
}
|
|
312
|
-
),
|
|
313
|
-
/* @__PURE__ */ jsx("strong", { children: virtualAgent?.name })
|
|
314
|
-
]
|
|
315
|
-
}
|
|
316
|
-
),
|
|
317
|
-
/* @__PURE__ */ jsx(
|
|
318
|
-
ReactMarkdown,
|
|
319
|
-
{
|
|
320
|
-
remarkPlugins: [[remarkGfm, { singleTilde: false }]],
|
|
321
|
-
components: {
|
|
322
|
-
p: ({ ...props }) => /* @__PURE__ */ jsx(
|
|
323
|
-
"p",
|
|
324
|
-
{
|
|
325
|
-
style: { margin: 0, fontSize: "inherit" },
|
|
326
|
-
title: new Date(msg.$timestamp).toLocaleString(),
|
|
327
|
-
...props
|
|
328
|
-
}
|
|
329
|
-
)
|
|
330
|
-
},
|
|
331
|
-
children: msg.content
|
|
332
|
-
}
|
|
333
|
-
)
|
|
334
|
-
]
|
|
335
|
-
}
|
|
336
|
-
),
|
|
337
|
-
/* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "#888", marginTop: 2 } })
|
|
338
|
-
]
|
|
339
|
-
},
|
|
340
|
-
msg.$index
|
|
341
|
-
),
|
|
342
|
-
msg.type == "inline_button" && Array.isArray(msg.buttons) && msg.buttons.length > 0 && /* @__PURE__ */ jsx("div", { className: inline_button_wrapper, children: msg.buttons.length !== 0 && Array.isArray(msg.buttons) && msg.buttons.map((button, index) => {
|
|
343
|
-
const lastItem = msg.buttons && msg.buttons?.length - 1;
|
|
344
|
-
return /* @__PURE__ */ jsx(
|
|
345
|
-
"button",
|
|
346
|
-
{
|
|
347
|
-
className: inline_button,
|
|
348
|
-
style: {
|
|
349
|
-
borderRadius: "0px",
|
|
350
|
-
borderTopLeftRadius: [0].includes(index) ? 8 : 0,
|
|
351
|
-
borderTopRightRadius: [0].includes(index) ? 8 : 0,
|
|
352
|
-
borderBottomLeftRadius: [lastItem].includes(index) ? 8 : 0,
|
|
353
|
-
borderBottomRightRadius: [lastItem].includes(index) ? 8 : 0
|
|
354
|
-
},
|
|
355
|
-
onClick: () => {
|
|
356
|
-
onSend(button?.title);
|
|
357
|
-
},
|
|
358
|
-
children: button.title
|
|
359
|
-
},
|
|
360
|
-
index
|
|
361
|
-
);
|
|
362
|
-
}) }),
|
|
363
|
-
msg.event == "chatEnded" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
364
|
-
/* @__PURE__ */ jsxs(
|
|
365
|
-
"div",
|
|
366
|
-
{
|
|
367
|
-
title: (/* @__PURE__ */ new Date()).toLocaleString(),
|
|
368
|
-
style: {
|
|
369
|
-
fontSize: 12,
|
|
370
|
-
color: "#888",
|
|
371
|
-
marginBottom: 4,
|
|
372
|
-
textAlign: "center"
|
|
373
|
-
},
|
|
374
|
-
children: [
|
|
375
|
-
"Thank you for chatting!",
|
|
376
|
-
/* @__PURE__ */ jsx("br", {}),
|
|
377
|
-
" This conversation has ended."
|
|
378
|
-
]
|
|
379
|
-
}
|
|
380
|
-
),
|
|
381
|
-
/* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
|
|
382
|
-
] })
|
|
383
|
-
] }, msg.$index)),
|
|
384
|
-
showReconnect && /* @__PURE__ */ jsx(
|
|
385
|
-
"button",
|
|
386
|
-
{
|
|
387
|
-
style: { margin: "12px auto", display: "block" },
|
|
388
|
-
onClick: () => {
|
|
389
|
-
},
|
|
390
|
-
children: "Reconnect Chat"
|
|
391
|
-
}
|
|
392
|
-
),
|
|
393
|
-
/* @__PURE__ */ jsx("div", { ref: messagesEndRef })
|
|
394
|
-
] }),
|
|
395
|
-
/* @__PURE__ */ jsxs(
|
|
396
|
-
"form",
|
|
397
|
-
{
|
|
398
|
-
onSubmit: handleSend,
|
|
399
|
-
style: {
|
|
400
|
-
borderTop: "1px solid #eee",
|
|
401
|
-
display: "flex",
|
|
402
|
-
gap: 8
|
|
403
|
-
},
|
|
404
|
-
children: [
|
|
405
|
-
/* @__PURE__ */ jsx(
|
|
406
|
-
"input",
|
|
407
|
-
{
|
|
408
|
-
type: "text",
|
|
409
|
-
value: input,
|
|
410
|
-
onChange: (e) => setInput(e.target.value),
|
|
411
|
-
placeholder: "Ask something...",
|
|
412
|
-
className: inputStyle,
|
|
413
|
-
autoFocus: true,
|
|
414
|
-
disabled: inputDisabled || status !== "connected" || escalationDeflected
|
|
415
|
-
}
|
|
416
|
-
),
|
|
417
|
-
/* @__PURE__ */ jsx(
|
|
418
|
-
"button",
|
|
419
|
-
{
|
|
420
|
-
className: clsx(sendButtonStyle, input.trim().length > 0 && "active"),
|
|
421
|
-
type: "submit",
|
|
422
|
-
title: "Send message",
|
|
423
|
-
disabled: inputDisabled || status !== "connected" || !input.trim(),
|
|
424
|
-
children: /* @__PURE__ */ jsxs(
|
|
425
|
-
"svg",
|
|
426
|
-
{
|
|
427
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
428
|
-
id: "send-icon",
|
|
429
|
-
width: 24,
|
|
430
|
-
height: 24,
|
|
431
|
-
children: [
|
|
432
|
-
/* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }),
|
|
433
|
-
/* @__PURE__ */ jsx("path", { d: "M0 0h24v24H0z", fill: "none" })
|
|
434
|
-
]
|
|
435
|
-
}
|
|
436
|
-
)
|
|
437
|
-
}
|
|
438
|
-
)
|
|
439
|
-
]
|
|
440
|
-
}
|
|
441
|
-
)
|
|
442
|
-
] });
|
|
443
|
-
};
|
|
444
|
-
export {
|
|
445
|
-
ChatWindow
|
|
446
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type ChatbotProps = {
|
|
2
|
-
project?: "axos" | "ufb";
|
|
3
|
-
debug?: boolean;
|
|
4
|
-
};
|
|
5
|
-
export declare const Chatbot: ({ project, projectEnv, menuOption, }: {
|
|
6
|
-
project?: "axos" | "ufb";
|
|
7
|
-
projectEnv?: "dev" | "qa" | "uat" | "stg" | "prod";
|
|
8
|
-
menuOption?: "Support Virtual Agent" | string;
|
|
9
|
-
debug?: boolean;
|
|
10
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
package/dist/Chatbot/Chatbot.js
DELETED
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
-
import { authenticate } from "./authenticate.js";
|
|
4
|
-
import { Bubble } from "./Bubble.js";
|
|
5
|
-
import { chatbotUFB, chatbotAXB } from "./Chatbot.css.js";
|
|
6
|
-
import { ChatWindow } from "./ChatWindow.js";
|
|
7
|
-
import { useOpenChat } from "./store/chat.js";
|
|
8
|
-
import { useMessages } from "./store/messages.js";
|
|
9
|
-
import { Logger, consoleLoggerHandler, Client } from "@ujet/websdk-headless";
|
|
10
|
-
import { useRef, useState } from "react";
|
|
11
|
-
import { useMount, useUnmount } from "react-use";
|
|
12
|
-
const Chatbot = ({
|
|
13
|
-
project = "axos",
|
|
14
|
-
projectEnv = "dev",
|
|
15
|
-
menuOption = "Support Virtual Agent"
|
|
16
|
-
}) => {
|
|
17
|
-
const { hasOpenedOnce, toggle, reset } = useOpenChat();
|
|
18
|
-
const { addMessage, addMessages, clearMessages, messages } = useMessages();
|
|
19
|
-
const clientRef = useRef(null);
|
|
20
|
-
const menuRef = useRef(null);
|
|
21
|
-
const isMountedRef = useRef(false);
|
|
22
|
-
const hasLoadedBefore = useRef(true);
|
|
23
|
-
const chatRef = useRef(null);
|
|
24
|
-
const agent_virtual = useRef(null);
|
|
25
|
-
const [status, setStatus] = useState("idle");
|
|
26
|
-
const [hasStarted, setHasStarted] = useState(false);
|
|
27
|
-
const brandMap = /* @__PURE__ */ new Map([
|
|
28
|
-
["axos", 1],
|
|
29
|
-
["ufb", 3]
|
|
30
|
-
]);
|
|
31
|
-
const custom_data = {
|
|
32
|
-
unsigned: {
|
|
33
|
-
facingBrandId: {
|
|
34
|
-
label: "facingBrandId",
|
|
35
|
-
value: `${brandMap.get(project) || 1}`
|
|
36
|
-
},
|
|
37
|
-
channel: {
|
|
38
|
-
label: "channel",
|
|
39
|
-
value: "in_web"
|
|
40
|
-
},
|
|
41
|
-
user_auth: {
|
|
42
|
-
label: "user_auth",
|
|
43
|
-
value: "false"
|
|
44
|
-
},
|
|
45
|
-
env: {
|
|
46
|
-
label: "env",
|
|
47
|
-
value: projectEnv === "dev" ? "uat" : projectEnv
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
if (projectEnv !== "prod") {
|
|
52
|
-
Logger.addHandler(consoleLoggerHandler);
|
|
53
|
-
}
|
|
54
|
-
const onReadyHandler = async () => {
|
|
55
|
-
console.log("Chat client is ready");
|
|
56
|
-
};
|
|
57
|
-
const onAuthenticatedHandler = async () => {
|
|
58
|
-
console.log("Chat client is authenticated");
|
|
59
|
-
};
|
|
60
|
-
const onChatOngoingHandler = async (chat) => {
|
|
61
|
-
console.log("Ongoing chat:", chat);
|
|
62
|
-
};
|
|
63
|
-
const onChatMessageHandler = async (message) => {
|
|
64
|
-
console.log("Received message:", message);
|
|
65
|
-
addMessage(message);
|
|
66
|
-
};
|
|
67
|
-
const onChatTypingStartedHandler = async (identity) => {
|
|
68
|
-
console.log("Typing started by:", identity);
|
|
69
|
-
};
|
|
70
|
-
const onChatDisconnectedHandler = async () => {
|
|
71
|
-
console.log("Chat disconnected");
|
|
72
|
-
setStatus("idle");
|
|
73
|
-
};
|
|
74
|
-
const onDismissedHandler = async () => {
|
|
75
|
-
console.log("Chat dismissed");
|
|
76
|
-
};
|
|
77
|
-
const onTimeoutHandler = async () => {
|
|
78
|
-
console.log("Chat timeout");
|
|
79
|
-
};
|
|
80
|
-
const onEndedHandler = async () => {
|
|
81
|
-
console.log("Chat ended");
|
|
82
|
-
setStatus("finished");
|
|
83
|
-
};
|
|
84
|
-
const onDestroyedHandler = async () => {
|
|
85
|
-
console.log("Chat destroyed");
|
|
86
|
-
};
|
|
87
|
-
const onChatMemberLeftHandler = async (identity) => {
|
|
88
|
-
console.log("Chat member left:", identity);
|
|
89
|
-
};
|
|
90
|
-
const onChatConnectedHandler = async () => {
|
|
91
|
-
setStatus("connected");
|
|
92
|
-
console.log("connected");
|
|
93
|
-
const messages2 = await clientRef.current?.fetchMessages();
|
|
94
|
-
if (messages2) {
|
|
95
|
-
addMessages(messages2);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const registerEventHandlers = () => {
|
|
99
|
-
clientRef.current?.on("ready", onReadyHandler);
|
|
100
|
-
clientRef.current?.on("authenticated", onAuthenticatedHandler);
|
|
101
|
-
clientRef.current?.on("chat.ongoing", onChatOngoingHandler);
|
|
102
|
-
clientRef.current?.on("chat.message", onChatMessageHandler);
|
|
103
|
-
clientRef.current?.on("chat.typingStarted", onChatTypingStartedHandler);
|
|
104
|
-
clientRef.current?.on("chat.disconnected", onChatDisconnectedHandler);
|
|
105
|
-
clientRef.current?.on("chat.dismissed", onDismissedHandler);
|
|
106
|
-
clientRef.current?.on("chat.timeout", onTimeoutHandler);
|
|
107
|
-
clientRef.current?.on("chat.ended", onEndedHandler);
|
|
108
|
-
clientRef.current?.on("chat.destroyed", onDestroyedHandler);
|
|
109
|
-
clientRef.current?.on("chat.memberLeft", onChatMemberLeftHandler);
|
|
110
|
-
clientRef?.current?.on("chat.connected", onChatConnectedHandler);
|
|
111
|
-
};
|
|
112
|
-
const deregisterEventHandlers = () => {
|
|
113
|
-
clientRef.current?.off("ready", onReadyHandler);
|
|
114
|
-
clientRef.current?.off("authenticated", onAuthenticatedHandler);
|
|
115
|
-
clientRef.current?.off("chat.ongoing", onDismissedHandler);
|
|
116
|
-
clientRef.current?.off("chat.message", onChatMessageHandler);
|
|
117
|
-
clientRef.current?.off("chat.typingStarted", onChatTypingStartedHandler);
|
|
118
|
-
clientRef.current?.off("chat.disconnected", onChatDisconnectedHandler);
|
|
119
|
-
clientRef.current?.off("chat.dismissed", onDismissedHandler);
|
|
120
|
-
clientRef.current?.off("chat.timeout", onTimeoutHandler);
|
|
121
|
-
clientRef.current?.off("chat.ended", onEndedHandler);
|
|
122
|
-
clientRef.current?.off("chat.destroyed", onDestroyedHandler);
|
|
123
|
-
clientRef.current?.off("chat.memberLeft", onChatMemberLeftHandler);
|
|
124
|
-
clientRef.current?.off("chat.connected", onChatConnectedHandler);
|
|
125
|
-
};
|
|
126
|
-
const createClient = async () => {
|
|
127
|
-
if (clientRef.current) return;
|
|
128
|
-
const client = new Client({
|
|
129
|
-
companyId: process.env.CCAI_COMPANY_ID || "",
|
|
130
|
-
tenant: process.env.CCAI_TENANT_NAME || "",
|
|
131
|
-
host: process.env.CCAI_HOST || "",
|
|
132
|
-
// or your region
|
|
133
|
-
authenticate
|
|
134
|
-
});
|
|
135
|
-
isMountedRef.current = true;
|
|
136
|
-
clientRef.current = client;
|
|
137
|
-
menuRef.current = await client.getMenus();
|
|
138
|
-
console.log("menus:", menuRef.current);
|
|
139
|
-
registerEventHandlers();
|
|
140
|
-
return;
|
|
141
|
-
};
|
|
142
|
-
const startChat = async () => {
|
|
143
|
-
console.log("Starting chat");
|
|
144
|
-
const client = clientRef.current;
|
|
145
|
-
if (!client) return;
|
|
146
|
-
try {
|
|
147
|
-
const ongoingChat = await client.loadOngoingChat();
|
|
148
|
-
if (ongoingChat) {
|
|
149
|
-
console.log("Ongoing chat found:", ongoingChat);
|
|
150
|
-
console.log("Resuming chat:", ongoingChat.id);
|
|
151
|
-
chatRef.current = await client.resumeChat(ongoingChat.id);
|
|
152
|
-
agent_virtual.current = ongoingChat.agent;
|
|
153
|
-
return;
|
|
154
|
-
}
|
|
155
|
-
const foundMenu = menuRef.current.menus.find(
|
|
156
|
-
(menu) => menu.name === menuOption
|
|
157
|
-
);
|
|
158
|
-
const menuId = foundMenu && foundMenu.id;
|
|
159
|
-
console.log("Creating new chat with menu ID:", menuId);
|
|
160
|
-
const newChat = await client.createChat(menuId, { custom_data });
|
|
161
|
-
if (newChat !== null) {
|
|
162
|
-
chatRef.current = newChat;
|
|
163
|
-
console.log("Chat created id:", newChat.id);
|
|
164
|
-
}
|
|
165
|
-
} catch (err) {
|
|
166
|
-
console.error("Error creating chat:", err);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
const handleClick = async () => {
|
|
170
|
-
toggle();
|
|
171
|
-
if (hasStarted) return;
|
|
172
|
-
if (!hasOpenedOnce) {
|
|
173
|
-
await startChat();
|
|
174
|
-
setHasStarted(true);
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
const onSendMessage = (msg) => {
|
|
178
|
-
console.log("Sending message:", msg);
|
|
179
|
-
clientRef.current?.sendTextMessage(msg);
|
|
180
|
-
};
|
|
181
|
-
const onEndChat = async () => {
|
|
182
|
-
console.log("Ending chat");
|
|
183
|
-
if (chatRef.current) {
|
|
184
|
-
await clientRef.current?.finishChat();
|
|
185
|
-
await chatRef.current.destroy();
|
|
186
|
-
clearMessages();
|
|
187
|
-
chatRef.current = null;
|
|
188
|
-
console.log("Chat ended");
|
|
189
|
-
setHasStarted(false);
|
|
190
|
-
reset();
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
useMount(async () => {
|
|
194
|
-
console.log("Chatbot mounted");
|
|
195
|
-
if (isMountedRef.current) return;
|
|
196
|
-
isMountedRef.current = true;
|
|
197
|
-
await createClient();
|
|
198
|
-
});
|
|
199
|
-
useUnmount(() => {
|
|
200
|
-
console.log("Chatbot unmounted");
|
|
201
|
-
deregisterEventHandlers();
|
|
202
|
-
isMountedRef.current = false;
|
|
203
|
-
hasLoadedBefore.current = true;
|
|
204
|
-
});
|
|
205
|
-
return /* @__PURE__ */ jsxs("div", { className: project === "ufb" ? chatbotUFB : chatbotAXB, children: [
|
|
206
|
-
/* @__PURE__ */ jsx(Bubble, { onClick: handleClick }),
|
|
207
|
-
/* @__PURE__ */ jsx(
|
|
208
|
-
ChatWindow,
|
|
209
|
-
{
|
|
210
|
-
status,
|
|
211
|
-
virtualAgent: agent_virtual.current,
|
|
212
|
-
messages,
|
|
213
|
-
onSend: onSendMessage,
|
|
214
|
-
endChat: onEndChat
|
|
215
|
-
}
|
|
216
|
-
)
|
|
217
|
-
] });
|
|
218
|
-
};
|
|
219
|
-
export {
|
|
220
|
-
Chatbot
|
|
221
|
-
};
|