@axos-web-dev/shared-components 1.0.100-dev.5 → 1.0.100-dev.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/ATMLocator/ATMLocator.js +7 -1
  2. package/dist/ArticlesSet/ArticlesSet.js +2 -2
  3. package/dist/Auth/ErrorAlert.js +7 -1
  4. package/dist/Button/Button.js +7 -1
  5. package/dist/Calculators/BuyDownCalculator/index.js +1 -1
  6. package/dist/Calculators/Calculator.js +8 -2
  7. package/dist/Carousel/index.js +7 -1
  8. package/dist/Chatbot/Bubble.css.d.ts +2 -0
  9. package/dist/Chatbot/Bubble.css.js +7 -0
  10. package/dist/Chatbot/Bubble.d.ts +3 -0
  11. package/dist/Chatbot/Bubble.js +100 -0
  12. package/dist/Chatbot/Chat.d.ts +1 -0
  13. package/dist/Chatbot/Chat.js +165 -0
  14. package/dist/Chatbot/ChatWindow.css.d.ts +17 -0
  15. package/dist/Chatbot/ChatWindow.css.js +37 -0
  16. package/dist/Chatbot/ChatWindow.d.ts +29 -0
  17. package/dist/Chatbot/ChatWindow.js +366 -0
  18. package/dist/Chatbot/Chatbot.css.d.ts +2 -0
  19. package/dist/Chatbot/Chatbot.css.js +7 -0
  20. package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +1 -0
  21. package/dist/Chatbot/Chatbot.d.ts +5 -0
  22. package/dist/Chatbot/Chatbot.js +42 -0
  23. package/dist/Chatbot/EllipsisIcon.d.ts +4 -0
  24. package/dist/Chatbot/EllipsisIcon.js +19 -0
  25. package/dist/Chatbot/authenticate.d.ts +3 -0
  26. package/dist/Chatbot/authenticate.js +16 -0
  27. package/dist/Chatbot/index.d.ts +9 -0
  28. package/dist/Chatbot/index.js +39 -0
  29. package/dist/Chatbot/store/chat.d.ts +9 -0
  30. package/dist/Chatbot/store/chat.js +11 -0
  31. package/dist/Chatbot/store/messages.d.ts +15 -0
  32. package/dist/Chatbot/store/messages.js +13 -0
  33. package/dist/Chatbot/useHeadlessChat.d.ts +26 -0
  34. package/dist/Chatbot/useHeadlessChat.js +193 -0
  35. package/dist/Chevron/index.js +7 -1
  36. package/dist/Comparison/Comparison.js +7 -1
  37. package/dist/Comparison/ComparisonSet.js +33 -24
  38. package/dist/ExecutiveBio/ExecutiveBio.js +7 -1
  39. package/dist/FaqAccordion/index.js +7 -1
  40. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +7 -1
  41. package/dist/Forms/ApplyNow.js +7 -1
  42. package/dist/Forms/ContactUsBusiness.js +7 -1
  43. package/dist/Forms/ContactUsBusinessNameEmail.js +7 -1
  44. package/dist/Forms/ContactUsNMLSId.js +7 -1
  45. package/dist/Forms/CraPublicFile.js +7 -1
  46. package/dist/Forms/EmailOnly.js +7 -1
  47. package/dist/Forms/MortgageRate/MortgageRateForm.js +7 -1
  48. package/dist/Forms/MortgageRate/MortgageRateWatch.js +7 -1
  49. package/dist/Forms/MortgageWarehouseLending.js +7 -1
  50. package/dist/Forms/SuccesForm.js +8 -2
  51. package/dist/Hyperlink/index.js +7 -1
  52. package/dist/ImageLink/ImageLink.js +7 -1
  53. package/dist/ImageLink/ImageLinkSet.js +7 -1
  54. package/dist/ImageLink/index.js +7 -1
  55. package/dist/Insight/Featured/CategorySelector.js +7 -1
  56. package/dist/Insight/Featured/Featured.js +7 -1
  57. package/dist/Insight/Featured/Header.js +7 -1
  58. package/dist/Modal/Modal.js +7 -1
  59. package/dist/NavigationMenu/AxosALTS/NavData.js +7 -1
  60. package/dist/NavigationMenu/AxosALTS/index.js +7 -1
  61. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +7 -1
  62. package/dist/NavigationMenu/AxosBank/NavData.js +7 -1
  63. package/dist/NavigationMenu/AxosBank/SubNavBar.js +7 -1
  64. package/dist/NavigationMenu/AxosBank/index.js +7 -1
  65. package/dist/NavigationMenu/LaVictoire/NavData.js +7 -1
  66. package/dist/NavigationMenu/LaVictoire/index.js +7 -1
  67. package/dist/NavigationMenu/NavDataJson.js +7 -1
  68. package/dist/NavigationMenu/Navbar.js +7 -1
  69. package/dist/NavigationMenu/SignInNavButton.js +7 -1
  70. package/dist/SetContainer/SetContainer.js +7 -1
  71. package/dist/SocialMediaBar/iconsRepository.js +7 -1
  72. package/dist/Table/Table.d.ts +1 -1
  73. package/dist/VideoTile/VideoTile.js +7 -1
  74. package/dist/VideoWrapper/index.js +7 -1
  75. package/dist/WalnutIframe/wrapper.module.js +3 -3
  76. package/dist/assets/Chatbot/Bubble.css +51 -0
  77. package/dist/assets/Chatbot/ChatWindow.css +206 -0
  78. package/dist/assets/Comparison/Comparison.css +3 -1
  79. package/dist/assets/WalnutIframe/wrapper.css.css +49 -49
  80. package/dist/main.d.ts +1 -0
  81. package/dist/main.js +36 -0
  82. package/package.json +136 -133
@@ -0,0 +1,366 @@
1
+ "use client";
2
+ import { jsxs, jsx, Fragment as Fragment$1 } from "react/jsx-runtime";
3
+ import clsx from "clsx";
4
+ import React, { useRef, useEffect, Fragment } 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, button_reset, arrowFill, chatNetworkStatus, notificationStyle, messageStyle, inline_button_wrapper, inline_button, endChatButtonStyle, messagesContainerStyle, inputStyle, sendButtonStyle, windowStyle, windowOpenStyle } from "./ChatWindow.css.js";
9
+ import { EllipsisIcon } from "./EllipsisIcon.js";
10
+ import { useOpenChat } from "./store/chat.js";
11
+ const ChatWindow = ({
12
+ messages,
13
+ status = "connected",
14
+ onSend,
15
+ inputDisabled = false,
16
+ onClose,
17
+ endChat = () => {
18
+ console.log("End chat");
19
+ },
20
+ showReconnect = false,
21
+ virtualAgent
22
+ }) => {
23
+ const [mounted, setMounted] = React.useState(false);
24
+ const [menuOpen, setMenuOpen] = React.useState(false);
25
+ const [showEndChatDialog, setShowEndChatDialog] = React.useState(false);
26
+ const state = useNetworkState();
27
+ const [input, setInput] = React.useState("");
28
+ const messagesEndRef = useRef(null);
29
+ const isOpen = useOpenChat((state2) => state2.isOpen);
30
+ useEffect(() => {
31
+ messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
32
+ }, [messages]);
33
+ const handleSend = (e) => {
34
+ e.preventDefault();
35
+ if (input.trim()) {
36
+ onSend(input);
37
+ setInput("");
38
+ }
39
+ };
40
+ useMount(() => {
41
+ setMounted(true);
42
+ });
43
+ const project = process.env.CCAI_PROJECT_ID;
44
+ const isAxos = project === "axos";
45
+ const endUserBg = isAxos ? "#14263d" : "#323339";
46
+ const chatbotBg = isAxos ? "#E9F8FF" : "#EAE8E8";
47
+ return /* @__PURE__ */ jsxs("div", { className: clsx(windowStyle, isOpen && windowOpenStyle), children: [
48
+ /* @__PURE__ */ jsxs("div", { className: windowBarStyle, children: [
49
+ /* @__PURE__ */ jsxs("div", { className: "flex middle", style: { paddingBlock: "6px" }, children: [
50
+ /* @__PURE__ */ jsx(
51
+ "img",
52
+ {
53
+ src: "https://www.axos.com/images/2xmVfQm5l0HWOKjgxQO1Iw/axb-assistant.svg",
54
+ style: { marginRight: 12 },
55
+ height: 18,
56
+ width: 18
57
+ }
58
+ ),
59
+ /* @__PURE__ */ jsx("h2", { className: chat_title, children: "Evo Virtual Assistant" })
60
+ ] }),
61
+ /* @__PURE__ */ jsx(
62
+ "button",
63
+ {
64
+ onClick: () => {
65
+ setMenuOpen(!menuOpen);
66
+ },
67
+ style: {
68
+ border: "none",
69
+ background: "transparent",
70
+ marginLeft: "auto",
71
+ cursor: "pointer",
72
+ padding: 0,
73
+ display: "flex",
74
+ alignContent: "center"
75
+ },
76
+ children: /* @__PURE__ */ jsx(EllipsisIcon, { color: "#fff" })
77
+ }
78
+ ),
79
+ menuOpen && /* @__PURE__ */ jsx("ul", { className: clsx(chatbotMenu), children: /* @__PURE__ */ jsx("li", { className: chatbotMenuItem, children: /* @__PURE__ */ jsx(
80
+ "button",
81
+ {
82
+ type: "button",
83
+ onClick: () => {
84
+ setShowEndChatDialog(true);
85
+ setMenuOpen(false);
86
+ },
87
+ style: { width: "100%" },
88
+ children: "Finish chat"
89
+ }
90
+ ) }) }),
91
+ showEndChatDialog && /* @__PURE__ */ jsx(
92
+ "dialog",
93
+ {
94
+ open: showEndChatDialog,
95
+ style: {
96
+ padding: "1rem",
97
+ borderRadius: 8,
98
+ background: "#fff",
99
+ color: "#000",
100
+ border: "none",
101
+ outline: "none",
102
+ maxWidth: "90%",
103
+ top: "25%"
104
+ },
105
+ children: /* @__PURE__ */ jsxs("form", { method: "dialog", children: [
106
+ /* @__PURE__ */ jsx("p", { children: "are you sure you want to end this chat?" }),
107
+ /* @__PURE__ */ jsx(
108
+ "button",
109
+ {
110
+ type: "submit",
111
+ onClick: () => {
112
+ endChat();
113
+ setShowEndChatDialog(false);
114
+ },
115
+ children: "Yes"
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsx(
119
+ "button",
120
+ {
121
+ type: "button",
122
+ onClick: () => {
123
+ setShowEndChatDialog(false);
124
+ },
125
+ children: "No"
126
+ }
127
+ )
128
+ ] })
129
+ }
130
+ ),
131
+ onClose && /* @__PURE__ */ jsx(
132
+ "button",
133
+ {
134
+ onClick: onClose,
135
+ className: button_reset,
136
+ "aria-label": "Close chat",
137
+ title: "Close",
138
+ children: /* @__PURE__ */ jsx(
139
+ "svg",
140
+ {
141
+ xmlns: "http://www.w3.org/2000/svg",
142
+ width: "24",
143
+ height: "24",
144
+ viewBox: "0 0 24 24",
145
+ fill: "none",
146
+ children: /* @__PURE__ */ jsx(
147
+ "path",
148
+ {
149
+ className: arrowFill,
150
+ d: "M2.46875 7.76574L11.9991 17.2961L21.5294 7.76574L20.4687 6.70508L11.9991 15.1749L3.52941 6.70508L2.46875 7.76574Z",
151
+ fill: "#98DDFF"
152
+ }
153
+ )
154
+ }
155
+ )
156
+ }
157
+ )
158
+ ] }),
159
+ /* @__PURE__ */ jsx("div", { className: clsx(chatNetworkStatus), children: mounted && !state.online ? /* @__PURE__ */ jsxs(
160
+ "div",
161
+ {
162
+ style: {
163
+ color: "#d32f2f",
164
+ textAlign: "center",
165
+ padding: "8px 0",
166
+ fontWeight: 500
167
+ },
168
+ children: [
169
+ /* @__PURE__ */ jsx(
170
+ "span",
171
+ {
172
+ role: "img",
173
+ "aria-label": "disconnected",
174
+ style: { marginRight: 6 },
175
+ children: "⚠️"
176
+ }
177
+ ),
178
+ "You are currently disconnected. Please check your connection."
179
+ ]
180
+ }
181
+ ) : null }),
182
+ /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
183
+ messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment, { children: [
184
+ 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),
185
+ msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
186
+ /* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
187
+ " just left the conversation."
188
+ ] }, msg.$index),
189
+ msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationAccepted" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
190
+ "You are now connected with a",
191
+ " ",
192
+ msg.to_agent ? /* @__PURE__ */ jsx("strong", { children: msg?.to_agent?.name }) : "an agent"
193
+ ] }, msg.$index),
194
+ ["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsxs(
195
+ "div",
196
+ {
197
+ className: messageStyle,
198
+ style: {
199
+ textAlign: msg.$userType == "end_user" ? "right" : "left",
200
+ alignSelf: msg.$userType == "end_user" ? "flex-end" : "flex-start",
201
+ background: msg.$userType == "end_user" ? endUserBg : chatbotBg,
202
+ color: msg.$userType == "end_user" ? "#fff" : "#1F1F1F",
203
+ boxShadow: msg.$userType == "end_user" ? "0 1px 4px #b3e0ff55" : void 0
204
+ },
205
+ children: [
206
+ /* @__PURE__ */ jsxs(
207
+ "div",
208
+ {
209
+ style: {
210
+ fontSize: 13,
211
+ display: "flex",
212
+ flexDirection: "column",
213
+ gap: 4
214
+ },
215
+ children: [
216
+ msg.$userType == "virtual_agent" && /* @__PURE__ */ jsxs(
217
+ "div",
218
+ {
219
+ style: {
220
+ display: "flex",
221
+ // justifyContent: "center",
222
+ alignItems: "center",
223
+ gap: "8px"
224
+ },
225
+ children: [
226
+ /* @__PURE__ */ jsx(
227
+ "img",
228
+ {
229
+ width: 24,
230
+ height: 24,
231
+ src: virtualAgent?.avatar_url,
232
+ alt: "agent avatar"
233
+ }
234
+ ),
235
+ /* @__PURE__ */ jsx("strong", { children: virtualAgent?.name })
236
+ ]
237
+ }
238
+ ),
239
+ /* @__PURE__ */ jsx(
240
+ ReactMarkdown,
241
+ {
242
+ remarkPlugins: [[remarkGfm, { singleTilde: false }]],
243
+ components: {
244
+ p: ({ ...props }) => /* @__PURE__ */ jsx(
245
+ "p",
246
+ {
247
+ style: { margin: 0, fontSize: "inherit" },
248
+ title: new Date(msg.$timestamp).toLocaleString(),
249
+ ...props
250
+ }
251
+ )
252
+ },
253
+ children: msg.content
254
+ }
255
+ )
256
+ ]
257
+ }
258
+ ),
259
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "#888", marginTop: 2 } })
260
+ ]
261
+ },
262
+ msg.$index
263
+ ),
264
+ 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) => {
265
+ const lastItem = msg.buttons && msg.buttons?.length - 1;
266
+ return /* @__PURE__ */ jsx(
267
+ "button",
268
+ {
269
+ className: inline_button,
270
+ style: {
271
+ borderRadius: "0px",
272
+ borderTopLeftRadius: [0].includes(index) ? 8 : 0,
273
+ borderTopRightRadius: [0].includes(index) ? 8 : 0,
274
+ borderBottomLeftRadius: [lastItem].includes(index) ? 8 : 0,
275
+ borderBottomRightRadius: [lastItem].includes(index) ? 8 : 0
276
+ },
277
+ onClick: () => {
278
+ onSend(button?.title);
279
+ },
280
+ children: button.title
281
+ },
282
+ index
283
+ );
284
+ }) }),
285
+ msg.event == "chatEnded" && /* @__PURE__ */ jsxs(Fragment$1, { children: [
286
+ /* @__PURE__ */ jsxs(
287
+ "div",
288
+ {
289
+ title: (/* @__PURE__ */ new Date()).toLocaleString(),
290
+ style: {
291
+ fontSize: 12,
292
+ color: "#888",
293
+ marginBottom: 4,
294
+ textAlign: "center"
295
+ },
296
+ children: [
297
+ "Thank you for chatting!",
298
+ /* @__PURE__ */ jsx("br", {}),
299
+ " This conversation has ended."
300
+ ]
301
+ }
302
+ ),
303
+ /* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
304
+ ] })
305
+ ] }, msg.$index)),
306
+ showReconnect && /* @__PURE__ */ jsx(
307
+ "button",
308
+ {
309
+ style: { margin: "12px auto", display: "block" },
310
+ onClick: () => {
311
+ },
312
+ children: "Reconnect Chat"
313
+ }
314
+ ),
315
+ /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
316
+ ] }),
317
+ /* @__PURE__ */ jsxs(
318
+ "form",
319
+ {
320
+ onSubmit: handleSend,
321
+ style: {
322
+ borderTop: "1px solid #eee",
323
+ display: "flex",
324
+ gap: 8
325
+ },
326
+ children: [
327
+ /* @__PURE__ */ jsx(
328
+ "input",
329
+ {
330
+ type: "text",
331
+ value: input,
332
+ onChange: (e) => setInput(e.target.value),
333
+ placeholder: "Ask something...",
334
+ className: inputStyle,
335
+ disabled: inputDisabled || status !== "connected"
336
+ }
337
+ ),
338
+ /* @__PURE__ */ jsx(
339
+ "button",
340
+ {
341
+ className: clsx(sendButtonStyle, input.trim().length > 0 && "active"),
342
+ type: "submit",
343
+ disabled: inputDisabled || status !== "connected" || !input.trim(),
344
+ children: /* @__PURE__ */ jsxs(
345
+ "svg",
346
+ {
347
+ xmlns: "http://www.w3.org/2000/svg",
348
+ id: "send-icon",
349
+ width: 24,
350
+ height: 24,
351
+ children: [
352
+ /* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }),
353
+ /* @__PURE__ */ jsx("path", { d: "M0 0h24v24H0z", fill: "none" })
354
+ ]
355
+ }
356
+ )
357
+ }
358
+ )
359
+ ]
360
+ }
361
+ )
362
+ ] });
363
+ };
364
+ export {
365
+ ChatWindow
366
+ };
@@ -0,0 +1,2 @@
1
+ export declare const chatbotAXB: string;
2
+ export declare const chatbotUFB: string;
@@ -0,0 +1,7 @@
1
+ import "./Chatbot.css.ts.vanilla.css.js";
2
+ var chatbotAXB = "_1hpv6vm0";
3
+ var chatbotUFB = "_1hpv6vm1";
4
+ export {
5
+ chatbotAXB,
6
+ chatbotUFB
7
+ };
@@ -0,0 +1,5 @@
1
+ export type ChatbotProps = {
2
+ project?: "axos" | "ufb";
3
+ debug?: boolean;
4
+ };
5
+ export declare const Chatbot: (props: ChatbotProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,42 @@
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 { useHeadlessChat } from "./useHeadlessChat.js";
10
+ const Chatbot = (props) => {
11
+ const messages = useMessages((state) => state.messages);
12
+ const close = useOpenChat((state) => state.close);
13
+ const { status, sendMessage, showReconnect, endChat, virtualAgent } = useHeadlessChat({
14
+ companyId: process.env.CCAI_COMPANY_ID || "",
15
+ tenant: process.env.CCAI_TENANT_NAME || "",
16
+ host: process.env.CCAI_HOST || "",
17
+ // or your region
18
+ projectId: process.env.CCAI_PROJECT_ID || props.project || "axos",
19
+ getToken: authenticate,
20
+ debug: props.debug || process.env.NODE_ENV === "development"
21
+ });
22
+ return /* @__PURE__ */ jsxs("div", { className: props.project === "ufb" ? chatbotUFB : chatbotAXB, children: [
23
+ /* @__PURE__ */ jsx(Bubble, {}),
24
+ /* @__PURE__ */ jsx(
25
+ ChatWindow,
26
+ {
27
+ status,
28
+ onClose: close,
29
+ messages,
30
+ onSend: function(msg) {
31
+ sendMessage(msg);
32
+ },
33
+ endChat,
34
+ virtualAgent,
35
+ showReconnect
36
+ }
37
+ )
38
+ ] });
39
+ };
40
+ export {
41
+ Chatbot
42
+ };
@@ -0,0 +1,4 @@
1
+ export declare const EllipsisIcon: ({ size, color }: {
2
+ size?: number | undefined;
3
+ color?: string | undefined;
4
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,19 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ const EllipsisIcon = ({ size = 24, color = "currentColor" }) => /* @__PURE__ */ jsxs(
3
+ "svg",
4
+ {
5
+ width: size,
6
+ height: size,
7
+ viewBox: "0 0 24 24",
8
+ fill: "none",
9
+ "aria-hidden": "true",
10
+ children: [
11
+ /* @__PURE__ */ jsx("circle", { cx: "5", cy: "12", r: "2", fill: color }),
12
+ /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "2", fill: color }),
13
+ /* @__PURE__ */ jsx("circle", { cx: "19", cy: "12", r: "2", fill: color })
14
+ ]
15
+ }
16
+ );
17
+ export {
18
+ EllipsisIcon
19
+ };
@@ -0,0 +1,3 @@
1
+ export declare const authenticate: () => Promise<{
2
+ token: any;
3
+ }>;
@@ -0,0 +1,16 @@
1
+ const AUTH_URL = process.env.AUTH_CHAT_URL || "http://localhost:3000/api/auth/token";
2
+ const authenticate = async () => {
3
+ const res = await fetch(AUTH_URL, {
4
+ method: "GET",
5
+ headers: {
6
+ "Content-Type": "application/json"
7
+ }
8
+ });
9
+ const data = await res.json();
10
+ return {
11
+ token: data.token
12
+ };
13
+ };
14
+ export {
15
+ authenticate
16
+ };
@@ -0,0 +1,9 @@
1
+ export * from './Bubble';
2
+ export * from './Bubble.css';
3
+ export * from './Chatbot';
4
+ export * from './Chatbot.css';
5
+ export * from './ChatWindow';
6
+ export * from './ChatWindow.css';
7
+ export * from './store/chat';
8
+ export * from './store/messages';
9
+ export * from './useHeadlessChat';
@@ -0,0 +1,39 @@
1
+ "use client";
2
+ import { Bubble } from "./Bubble.js";
3
+ import { bubbleWrapper, svgFill } from "./Bubble.css.js";
4
+ import { Chatbot } from "./Chatbot.js";
5
+ import { chatbotAXB, chatbotUFB } from "./Chatbot.css.js";
6
+ import { ChatWindow } from "./ChatWindow.js";
7
+ import { arrowFill, button_reset, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
8
+ import { useOpenChat } from "./store/chat.js";
9
+ import { useMessages } from "./store/messages.js";
10
+ import { useHeadlessChat } from "./useHeadlessChat.js";
11
+ export {
12
+ Bubble,
13
+ ChatWindow,
14
+ Chatbot,
15
+ arrowFill,
16
+ bubbleWrapper,
17
+ button_reset,
18
+ chatNetworkStatus,
19
+ chat_title,
20
+ chatbotAXB,
21
+ chatbotMenu,
22
+ chatbotMenuItem,
23
+ chatbotUFB,
24
+ endChatButtonStyle,
25
+ inline_button,
26
+ inline_button_wrapper,
27
+ inputStyle,
28
+ messageStyle,
29
+ messagesContainerStyle,
30
+ notificationStyle,
31
+ sendButtonStyle,
32
+ svgFill,
33
+ useHeadlessChat,
34
+ useMessages,
35
+ useOpenChat,
36
+ windowBarStyle,
37
+ windowOpenStyle,
38
+ windowStyle
39
+ };
@@ -0,0 +1,9 @@
1
+ interface OpenChatState {
2
+ isOpen: boolean;
3
+ toggle: () => void;
4
+ open: () => void;
5
+ close: () => void;
6
+ reset: () => void;
7
+ }
8
+ export declare const useOpenChat: import('zustand').UseBoundStore<import('zustand').StoreApi<OpenChatState>>;
9
+ export {};
@@ -0,0 +1,11 @@
1
+ import { create } from "zustand";
2
+ const useOpenChat = create((set) => ({
3
+ isOpen: false,
4
+ toggle: () => set((state) => ({ isOpen: !state.isOpen })),
5
+ open: () => set({ isOpen: true }),
6
+ close: () => set({ isOpen: false }),
7
+ reset: () => set({ isOpen: false })
8
+ }));
9
+ export {
10
+ useOpenChat
11
+ };
@@ -0,0 +1,15 @@
1
+ import { MessageResponse } from '@ujet/websdk-headless';
2
+
3
+ interface MessageStore {
4
+ messages: MessageResponse[];
5
+ addMessage: (message: MessageResponse) => void;
6
+ removeMessage: (id: string) => void;
7
+ addMessages: (newMessages: MessageResponse[]) => void;
8
+ clearMessages: () => void;
9
+ }
10
+ export interface Message {
11
+ id: string;
12
+ text: string;
13
+ }
14
+ export declare const useMessages: import('zustand').UseBoundStore<import('zustand').StoreApi<MessageStore>>;
15
+ export {};
@@ -0,0 +1,13 @@
1
+ import { create } from "zustand";
2
+ const useMessages = create((set) => ({
3
+ messages: [],
4
+ addMessage: (message) => set((state) => ({ messages: [...state.messages, message] })),
5
+ removeMessage: (id) => set((state) => ({
6
+ messages: state.messages.filter((msg) => msg.id !== id)
7
+ })),
8
+ addMessages: (newMessages) => set((state) => ({ messages: [...state.messages, ...newMessages] })),
9
+ clearMessages: () => set({ messages: [] })
10
+ }));
11
+ export {
12
+ useMessages
13
+ };
@@ -0,0 +1,26 @@
1
+ import { TokenResponse } from '@ujet/websdk-headless';
2
+
3
+ interface UseHeadlessChatOptions {
4
+ companyId: string;
5
+ tenant: string;
6
+ host: string;
7
+ getToken: () => Promise<TokenResponse>;
8
+ channelId?: string;
9
+ projectId?: "axos" | "" | "ufb" | string;
10
+ debug?: boolean;
11
+ }
12
+ export interface ChatMessage {
13
+ id: string;
14
+ body: string;
15
+ sender?: string;
16
+ timestamp?: string;
17
+ }
18
+ export declare function useHeadlessChat({ companyId, tenant, host, getToken, projectId, debug, }: UseHeadlessChatOptions): {
19
+ status: "error" | "idle" | "connected" | "connecting" | "finished";
20
+ sendMessage: (body: string) => Promise<void>;
21
+ showReconnect: boolean;
22
+ setShowReconnect: import('react').Dispatch<import('react').SetStateAction<boolean>>;
23
+ endChat: () => Promise<void>;
24
+ virtualAgent: any;
25
+ };
26
+ export {};