@axos-web-dev/shared-components 1.0.99 → 1.0.100-chat.1

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 (162) hide show
  1. package/dist/ATMLocator/ATMLocator.js +8 -1
  2. package/dist/ArticlesSet/ArticlesSet.js +2 -2
  3. package/dist/Auth/ErrorAlert.js +10 -3
  4. package/dist/Blockquote/Blockquote.module.js +3 -3
  5. package/dist/Button/Button.js +10 -3
  6. package/dist/Calculators/Calculator.js +23 -4
  7. package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.d.ts +9 -0
  8. package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.js +219 -0
  9. package/dist/Calculators/MaxLoanCalculator/index.js +22 -5
  10. package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.d.ts +1 -0
  11. package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js +2 -0
  12. package/dist/Calculators/MonthlyPaymentCalculator/index.js +15 -5
  13. package/dist/Calculators/index.d.ts +2 -1
  14. package/dist/Calculators/index.js +3 -1
  15. package/dist/Carousel/index.js +10 -3
  16. package/dist/Chatbot/Bubble.css.d.ts +2 -0
  17. package/dist/Chatbot/Bubble.css.js +8 -0
  18. package/dist/Chatbot/Bubble.d.ts +3 -0
  19. package/dist/Chatbot/Bubble.js +100 -0
  20. package/dist/Chatbot/Chat.d.ts +1 -0
  21. package/dist/Chatbot/Chat.js +165 -0
  22. package/dist/Chatbot/ChatWindow.css.d.ts +16 -0
  23. package/dist/Chatbot/ChatWindow.css.js +35 -0
  24. package/dist/Chatbot/ChatWindow.d.ts +29 -0
  25. package/dist/Chatbot/ChatWindow.js +329 -0
  26. package/dist/Chatbot/Chatbot.css.d.ts +2 -0
  27. package/dist/Chatbot/Chatbot.css.js +6 -0
  28. package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +1 -0
  29. package/dist/Chatbot/Chatbot.d.ts +5 -0
  30. package/dist/Chatbot/Chatbot.js +42 -0
  31. package/dist/Chatbot/EllipsisIcon.d.ts +4 -0
  32. package/dist/Chatbot/EllipsisIcon.js +19 -0
  33. package/dist/Chatbot/authenticate.d.ts +3 -0
  34. package/dist/Chatbot/authenticate.js +16 -0
  35. package/dist/Chatbot/index.d.ts +9 -0
  36. package/dist/Chatbot/index.js +38 -0
  37. package/dist/Chatbot/store/chat.d.ts +9 -0
  38. package/dist/Chatbot/store/chat.js +11 -0
  39. package/dist/Chatbot/store/messages.d.ts +15 -0
  40. package/dist/Chatbot/store/messages.js +13 -0
  41. package/dist/Chatbot/useHeadlessChat.d.ts +26 -0
  42. package/dist/Chatbot/useHeadlessChat.js +193 -0
  43. package/dist/Chevron/index.js +10 -3
  44. package/dist/Comparison/Comparison.js +10 -3
  45. package/dist/ExecutiveBio/ExecutiveBio.js +10 -3
  46. package/dist/FaqAccordion/index.js +10 -3
  47. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +10 -3
  48. package/dist/Forms/ApplicationStart.d.ts +1 -1
  49. package/dist/Forms/ApplicationStart.js +111 -89
  50. package/dist/Forms/ApplyNow.d.ts +2 -2
  51. package/dist/Forms/ApplyNow.js +178 -146
  52. package/dist/Forms/ClearingForm.d.ts +1 -1
  53. package/dist/Forms/ClearingForm.js +184 -162
  54. package/dist/Forms/CommercialDeposits.d.ts +1 -1
  55. package/dist/Forms/CommercialDeposits.js +201 -179
  56. package/dist/Forms/CommercialLending.d.ts +1 -1
  57. package/dist/Forms/CommercialLending.js +278 -256
  58. package/dist/Forms/CommercialPremiumFinance.d.ts +1 -1
  59. package/dist/Forms/CommercialPremiumFinance.js +128 -106
  60. package/dist/Forms/ContactCompany.d.ts +1 -1
  61. package/dist/Forms/ContactCompany.js +113 -91
  62. package/dist/Forms/ContactCompanyTitle.d.ts +1 -1
  63. package/dist/Forms/ContactCompanyTitle.js +127 -105
  64. package/dist/Forms/ContactUs.d.ts +1 -1
  65. package/dist/Forms/ContactUs.js +99 -77
  66. package/dist/Forms/ContactUsAAS.d.ts +1 -1
  67. package/dist/Forms/ContactUsAAS.js +180 -158
  68. package/dist/Forms/ContactUsBusiness.d.ts +1 -1
  69. package/dist/Forms/ContactUsBusiness.js +143 -115
  70. package/dist/Forms/ContactUsBusinessNameEmail.d.ts +1 -1
  71. package/dist/Forms/ContactUsBusinessNameEmail.js +112 -84
  72. package/dist/Forms/ContactUsLVF.d.ts +3 -1
  73. package/dist/Forms/ContactUsLVF.js +127 -101
  74. package/dist/Forms/ContactUsNMLSId.d.ts +1 -1
  75. package/dist/Forms/ContactUsNMLSId.js +126 -98
  76. package/dist/Forms/CpraRequest.d.ts +1 -1
  77. package/dist/Forms/CpraRequest.js +641 -619
  78. package/dist/Forms/CraPublicFile.d.ts +1 -1
  79. package/dist/Forms/CraPublicFile.js +118 -90
  80. package/dist/Forms/DealerServices.d.ts +1 -1
  81. package/dist/Forms/DealerServices.js +225 -204
  82. package/dist/Forms/EmailOnly.d.ts +1 -1
  83. package/dist/Forms/EmailOnly.js +65 -39
  84. package/dist/Forms/EmailUs.d.ts +1 -1
  85. package/dist/Forms/EmailUs.js +75 -53
  86. package/dist/Forms/FormProps.d.ts +3 -0
  87. package/dist/Forms/Forms.css.d.ts +18 -0
  88. package/dist/Forms/Forms.css.js +44 -38
  89. package/dist/Forms/HoneyPot/HoneyPot.css.d.ts +1 -0
  90. package/dist/Forms/HoneyPot/HoneyPot.css.js +5 -0
  91. package/dist/Forms/HoneyPot/index.d.ts +23 -0
  92. package/dist/Forms/HoneyPot/index.js +69 -0
  93. package/dist/Forms/MortgageRate/MortgageRateForm.d.ts +1 -1
  94. package/dist/Forms/MortgageRate/MortgageRateForm.js +376 -348
  95. package/dist/Forms/MortgageRate/MortgageRateWatch.js +10 -3
  96. package/dist/Forms/MortgageWarehouseLending.d.ts +11 -0
  97. package/dist/Forms/MortgageWarehouseLending.js +343 -0
  98. package/dist/Forms/QuickPricer/QuickPricerForm.d.ts +1 -1
  99. package/dist/Forms/QuickPricer/QuickPricerForm.js +624 -609
  100. package/dist/Forms/ScheduleCall.d.ts +1 -1
  101. package/dist/Forms/ScheduleCall.js +156 -134
  102. package/dist/Forms/ScheduleCallPremier.d.ts +1 -1
  103. package/dist/Forms/ScheduleCallPremier.js +178 -156
  104. package/dist/Forms/SuccesForm.js +14 -7
  105. package/dist/Forms/VendorQuestionnaire.d.ts +1 -1
  106. package/dist/Forms/VendorQuestionnaire.js +817 -795
  107. package/dist/Forms/WcplSurvey.d.ts +1 -1
  108. package/dist/Forms/WcplSurvey.js +112 -90
  109. package/dist/Forms/applynow-utils.d.ts +1 -0
  110. package/dist/Forms/applynow-utils.js +48 -0
  111. package/dist/Forms/index.d.ts +3 -0
  112. package/dist/Forms/index.js +12 -2
  113. package/dist/HeroBanner/HeroBanner.js +42 -1
  114. package/dist/Hyperlink/index.js +10 -3
  115. package/dist/IconBillboard/sections/CallToActionSection.js +2 -1
  116. package/dist/ImageBillboard/ExitIntentModal/useExitIntentModal.js +6 -1
  117. package/dist/ImageLink/ImageLink.js +10 -3
  118. package/dist/ImageLink/ImageLinkSet.js +10 -3
  119. package/dist/ImageLink/index.js +10 -3
  120. package/dist/Input/Input.js +3 -1
  121. package/dist/Insight/Featured/CategorySelector.js +10 -3
  122. package/dist/Insight/Featured/Featured.js +10 -3
  123. package/dist/Insight/Featured/Header.js +10 -3
  124. package/dist/Modal/Modal.js +10 -3
  125. package/dist/NavigationMenu/AxosALTS/NavData.js +10 -3
  126. package/dist/NavigationMenu/AxosALTS/index.js +10 -3
  127. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +16 -16
  128. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.d.ts +1 -0
  129. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +25 -7
  130. package/dist/NavigationMenu/AxosBank/NavBar.module.js +39 -39
  131. package/dist/NavigationMenu/AxosBank/NavData.js +10 -3
  132. package/dist/NavigationMenu/AxosBank/SubNavBar.js +32 -8
  133. package/dist/NavigationMenu/AxosBank/index.js +10 -3
  134. package/dist/NavigationMenu/LaVictoire/NavData.js +10 -3
  135. package/dist/NavigationMenu/LaVictoire/index.js +10 -3
  136. package/dist/NavigationMenu/NavDataJson.d.ts +2 -0
  137. package/dist/NavigationMenu/NavDataJson.js +315 -0
  138. package/dist/NavigationMenu/Navbar.d.ts +5 -0
  139. package/dist/NavigationMenu/Navbar.js +201 -0
  140. package/dist/NavigationMenu/SignInNavButton.d.ts +1 -0
  141. package/dist/NavigationMenu/SignInNavButton.js +369 -0
  142. package/dist/SetContainer/SetContainer.js +10 -3
  143. package/dist/SocialMediaBar/iconsRepository.js +10 -3
  144. package/dist/Table/Table.d.ts +1 -1
  145. package/dist/VideoTile/VideoTile.js +10 -3
  146. package/dist/VideoWrapper/index.js +10 -3
  147. package/dist/assets/Blockquote/Blockquote.css.css +68 -68
  148. package/dist/assets/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css +3 -0
  149. package/dist/assets/Chatbot/Bubble.css +51 -0
  150. package/dist/assets/Chatbot/ChatWindow.css +196 -0
  151. package/dist/assets/Forms/Forms.css +135 -105
  152. package/dist/assets/Forms/HoneyPot/HoneyPot.css +8 -0
  153. package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css.css +191 -191
  154. package/dist/assets/NavigationMenu/AxosBank/NavBar.css.css +473 -473
  155. package/dist/assets/utils/optimizeImage/optimizeImage.css.css +47 -47
  156. package/dist/icons/Logos/AXB.d.ts +8 -0
  157. package/dist/icons/Logos/AXB.js +74 -0
  158. package/dist/main.d.ts +1 -0
  159. package/dist/main.js +50 -3
  160. package/dist/utils/allowedAxosDomains.js +2 -1
  161. package/dist/utils/optimizeImage/optimizeImage.module.js +3 -3
  162. package/package.json +136 -133
@@ -0,0 +1,329 @@
1
+ "use client";
2
+ import { jsxs, jsx } 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, 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__ */ jsxs("div", { children: [
160
+ " ",
161
+ mounted && !state.online ? "Offline" : null,
162
+ " "
163
+ ] }),
164
+ /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
165
+ messages?.map((msg) => /* @__PURE__ */ jsxs(Fragment, { children: [
166
+ 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),
167
+ msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
168
+ /* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
169
+ " just left the conversation."
170
+ ] }, msg.$index),
171
+ msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationAccepted" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
172
+ "You are now connected with a",
173
+ " ",
174
+ msg.to_agent ? /* @__PURE__ */ jsx("strong", { children: msg?.to_agent?.name }) : "an agent"
175
+ ] }, msg.$index),
176
+ ["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsxs(
177
+ "div",
178
+ {
179
+ className: messageStyle,
180
+ style: {
181
+ textAlign: msg.$userType == "end_user" ? "right" : "left",
182
+ alignSelf: msg.$userType == "end_user" ? "flex-end" : "flex-start",
183
+ background: msg.$userType == "end_user" ? endUserBg : chatbotBg,
184
+ color: msg.$userType == "end_user" ? "#fff" : "#1F1F1F",
185
+ boxShadow: msg.$userType == "end_user" ? "0 1px 4px #b3e0ff55" : void 0
186
+ },
187
+ children: [
188
+ /* @__PURE__ */ jsxs(
189
+ "div",
190
+ {
191
+ style: {
192
+ fontSize: 13,
193
+ display: "flex",
194
+ flexDirection: "column",
195
+ gap: 4
196
+ },
197
+ children: [
198
+ msg.$userType == "virtual_agent" && /* @__PURE__ */ jsxs(
199
+ "div",
200
+ {
201
+ style: {
202
+ display: "flex",
203
+ // justifyContent: "center",
204
+ alignItems: "center",
205
+ gap: "8px"
206
+ },
207
+ children: [
208
+ /* @__PURE__ */ jsx(
209
+ "img",
210
+ {
211
+ width: 24,
212
+ height: 24,
213
+ src: virtualAgent?.avatar_url,
214
+ alt: "agent avatar"
215
+ }
216
+ ),
217
+ /* @__PURE__ */ jsx("strong", { children: virtualAgent?.name })
218
+ ]
219
+ }
220
+ ),
221
+ /* @__PURE__ */ jsx(
222
+ ReactMarkdown,
223
+ {
224
+ remarkPlugins: [[remarkGfm, { singleTilde: false }]],
225
+ components: {
226
+ p: ({ ...props }) => /* @__PURE__ */ jsx(
227
+ "p",
228
+ {
229
+ style: { margin: 0, fontSize: "inherit" },
230
+ title: new Date(msg.$timestamp).toLocaleString(),
231
+ ...props
232
+ }
233
+ )
234
+ },
235
+ children: msg.content
236
+ }
237
+ )
238
+ ]
239
+ }
240
+ ),
241
+ /* @__PURE__ */ jsx("div", { style: { fontSize: 10, color: "#888", marginTop: 2 } })
242
+ ]
243
+ },
244
+ msg.$index
245
+ ),
246
+ 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) => {
247
+ const lastItem = msg.buttons && msg.buttons?.length - 1;
248
+ return /* @__PURE__ */ jsx(
249
+ "button",
250
+ {
251
+ className: inline_button,
252
+ style: {
253
+ borderRadius: "0px",
254
+ borderTopLeftRadius: [0].includes(index) ? 8 : 0,
255
+ borderTopRightRadius: [0].includes(index) ? 8 : 0,
256
+ borderBottomLeftRadius: [lastItem].includes(index) ? 8 : 0,
257
+ borderBottomRightRadius: [lastItem].includes(index) ? 8 : 0
258
+ },
259
+ onClick: () => {
260
+ onSend(button?.title);
261
+ },
262
+ children: button.title
263
+ },
264
+ index
265
+ );
266
+ }) }),
267
+ msg.event == "chatEnded" && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: endChat, children: "End Chat" }) })
268
+ ] }, msg.$index)),
269
+ showReconnect && /* @__PURE__ */ jsx(
270
+ "button",
271
+ {
272
+ style: { margin: "12px auto", display: "block" },
273
+ onClick: () => {
274
+ },
275
+ children: "Reconnect Chat"
276
+ }
277
+ ),
278
+ /* @__PURE__ */ jsx("div", { ref: messagesEndRef })
279
+ ] }),
280
+ /* @__PURE__ */ jsxs(
281
+ "form",
282
+ {
283
+ onSubmit: handleSend,
284
+ style: {
285
+ borderTop: "1px solid #eee",
286
+ display: "flex",
287
+ gap: 8
288
+ },
289
+ children: [
290
+ /* @__PURE__ */ jsx(
291
+ "input",
292
+ {
293
+ type: "text",
294
+ value: input,
295
+ onChange: (e) => setInput(e.target.value),
296
+ placeholder: "Ask something...",
297
+ className: inputStyle,
298
+ disabled: inputDisabled || status !== "connected"
299
+ }
300
+ ),
301
+ /* @__PURE__ */ jsx(
302
+ "button",
303
+ {
304
+ className: clsx(sendButtonStyle, input.trim().length > 0 && "active"),
305
+ type: "submit",
306
+ disabled: inputDisabled || status !== "connected" || !input.trim(),
307
+ children: /* @__PURE__ */ jsxs(
308
+ "svg",
309
+ {
310
+ xmlns: "http://www.w3.org/2000/svg",
311
+ id: "send-icon",
312
+ width: 24,
313
+ height: 24,
314
+ children: [
315
+ /* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }),
316
+ /* @__PURE__ */ jsx("path", { d: "M0 0h24v24H0z", fill: "none" })
317
+ ]
318
+ }
319
+ )
320
+ }
321
+ )
322
+ ]
323
+ }
324
+ )
325
+ ] });
326
+ };
327
+ export {
328
+ ChatWindow
329
+ };
@@ -0,0 +1,2 @@
1
+ export declare const chatbotAXB: string;
2
+ export declare const chatbotUFB: string;
@@ -0,0 +1,6 @@
1
+ var chatbotAXB = "_1hpv6vm0";
2
+ var chatbotUFB = "_1hpv6vm1";
3
+ export {
4
+ chatbotAXB,
5
+ chatbotUFB
6
+ };
@@ -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,38 @@
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, 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
+ chat_title,
19
+ chatbotAXB,
20
+ chatbotMenu,
21
+ chatbotMenuItem,
22
+ chatbotUFB,
23
+ endChatButtonStyle,
24
+ inline_button,
25
+ inline_button_wrapper,
26
+ inputStyle,
27
+ messageStyle,
28
+ messagesContainerStyle,
29
+ notificationStyle,
30
+ sendButtonStyle,
31
+ svgFill,
32
+ useHeadlessChat,
33
+ useMessages,
34
+ useOpenChat,
35
+ windowBarStyle,
36
+ windowOpenStyle,
37
+ windowStyle
38
+ };
@@ -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 {};