@axos-web-dev/shared-components 1.0.77-patch.4 → 1.0.77-patch.40

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 (205) hide show
  1. package/dist/ATMLocator/ATMLocator.js +10 -3
  2. package/dist/Auth/ErrorAlert.js +12 -5
  3. package/dist/Button/Button.js +12 -5
  4. package/dist/Calculators/ApyCalculator/index.js +11 -5
  5. package/dist/Calculators/AxosOneCalculator/BalanceAPYCalculator.css.d.ts +1 -0
  6. package/dist/Calculators/AxosOneCalculator/BalanceAPYCalculator.css.js +3 -1
  7. package/dist/Calculators/AxosOneCalculator/index.d.ts +2 -0
  8. package/dist/Calculators/AxosOneCalculator/index.js +38 -20
  9. package/dist/Calculators/Calculator.d.ts +2 -0
  10. package/dist/Calculators/Calculator.js +29 -8
  11. package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.d.ts +9 -0
  12. package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.js +219 -0
  13. package/dist/Calculators/MaxLoanCalculator/index.js +22 -5
  14. package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.d.ts +1 -0
  15. package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js +2 -0
  16. package/dist/Calculators/MonthlyPaymentCalculator/index.js +15 -5
  17. package/dist/Calculators/SummitApyCalculator/index.js +15 -6
  18. package/dist/Calculators/index.d.ts +2 -1
  19. package/dist/Calculators/index.js +3 -1
  20. package/dist/Carousel/index.js +20 -13
  21. package/dist/Chatbot/Bubble.css.d.ts +2 -0
  22. package/dist/Chatbot/Bubble.css.js +7 -0
  23. package/dist/Chatbot/Bubble.d.ts +5 -0
  24. package/dist/Chatbot/Bubble.js +103 -0
  25. package/dist/Chatbot/Chat.d.ts +1 -0
  26. package/dist/Chatbot/Chat.js +165 -0
  27. package/dist/Chatbot/ChatWindow.css.d.ts +18 -0
  28. package/dist/Chatbot/ChatWindow.css.js +39 -0
  29. package/dist/Chatbot/ChatWindow.d.ts +26 -0
  30. package/dist/Chatbot/ChatWindow.js +446 -0
  31. package/dist/Chatbot/Chatbot.css.d.ts +2 -0
  32. package/dist/Chatbot/Chatbot.css.js +7 -0
  33. package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +1 -0
  34. package/dist/Chatbot/Chatbot.d.ts +10 -0
  35. package/dist/Chatbot/Chatbot.js +222 -0
  36. package/dist/Chatbot/EllipsisAnimation.d.ts +2 -0
  37. package/dist/Chatbot/EllipsisAnimation.js +85 -0
  38. package/dist/Chatbot/EllipsisIcon.d.ts +4 -0
  39. package/dist/Chatbot/EllipsisIcon.js +19 -0
  40. package/dist/Chatbot/authenticate.d.ts +3 -0
  41. package/dist/Chatbot/authenticate.js +16 -0
  42. package/dist/Chatbot/index.d.ts +8 -0
  43. package/dist/Chatbot/index.js +38 -0
  44. package/dist/Chatbot/store/chat.d.ts +10 -0
  45. package/dist/Chatbot/store/chat.js +18 -0
  46. package/dist/Chatbot/store/messages.d.ts +15 -0
  47. package/dist/Chatbot/store/messages.js +13 -0
  48. package/dist/Chatbot/useHeadlessChat.d.ts +27 -0
  49. package/dist/Chatbot/useHeadlessChat.js +240 -0
  50. package/dist/Chevron/index.js +12 -5
  51. package/dist/Comparison/Comparison.js +16 -9
  52. package/dist/Comparison/ComparisonSet.js +33 -24
  53. package/dist/ExecutiveBio/ExecutiveBio.js +12 -5
  54. package/dist/FaqAccordion/index.js +12 -5
  55. package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +30 -9
  56. package/dist/Forms/ApplicationStart.d.ts +1 -1
  57. package/dist/Forms/ApplicationStart.js +111 -89
  58. package/dist/Forms/ApplyNow.d.ts +2 -2
  59. package/dist/Forms/ApplyNow.js +180 -148
  60. package/dist/Forms/ClearingForm.d.ts +1 -1
  61. package/dist/Forms/ClearingForm.js +184 -162
  62. package/dist/Forms/CommercialDeposits.d.ts +1 -1
  63. package/dist/Forms/CommercialDeposits.js +201 -179
  64. package/dist/Forms/CommercialDepositsNoLendingOption.d.ts +16 -0
  65. package/dist/Forms/CommercialDepositsNoLendingOption.js +330 -0
  66. package/dist/Forms/CommercialLending.d.ts +1 -1
  67. package/dist/Forms/CommercialLending.js +278 -256
  68. package/dist/Forms/CommercialPremiumFinance.d.ts +1 -1
  69. package/dist/Forms/CommercialPremiumFinance.js +128 -106
  70. package/dist/Forms/ContactCompany.d.ts +1 -1
  71. package/dist/Forms/ContactCompany.js +113 -91
  72. package/dist/Forms/ContactCompanyTitle.d.ts +1 -1
  73. package/dist/Forms/ContactCompanyTitle.js +127 -105
  74. package/dist/Forms/ContactUs.d.ts +1 -1
  75. package/dist/Forms/ContactUs.js +99 -77
  76. package/dist/Forms/ContactUsAAS.d.ts +1 -1
  77. package/dist/Forms/ContactUsAAS.js +180 -158
  78. package/dist/Forms/ContactUsBusiness.d.ts +2 -2
  79. package/dist/Forms/ContactUsBusiness.js +146 -118
  80. package/dist/Forms/ContactUsBusinessNameEmail.d.ts +1 -1
  81. package/dist/Forms/ContactUsBusinessNameEmail.js +114 -86
  82. package/dist/Forms/ContactUsLVF.d.ts +7 -1
  83. package/dist/Forms/ContactUsLVF.js +133 -105
  84. package/dist/Forms/ContactUsNMLSId.d.ts +1 -1
  85. package/dist/Forms/ContactUsNMLSId.js +128 -100
  86. package/dist/Forms/CpraRequest.d.ts +1 -1
  87. package/dist/Forms/CpraRequest.js +641 -619
  88. package/dist/Forms/CraPublicFile.d.ts +1 -1
  89. package/dist/Forms/CraPublicFile.js +120 -92
  90. package/dist/Forms/DealerServices.d.ts +1 -1
  91. package/dist/Forms/DealerServices.js +225 -203
  92. package/dist/Forms/EmailOnly.d.ts +1 -1
  93. package/dist/Forms/EmailOnly.js +67 -41
  94. package/dist/Forms/EmailUs.d.ts +1 -1
  95. package/dist/Forms/EmailUs.js +75 -53
  96. package/dist/Forms/FormProps.d.ts +3 -0
  97. package/dist/Forms/Forms.css.d.ts +18 -0
  98. package/dist/Forms/Forms.css.js +44 -38
  99. package/dist/Forms/HoneyPot/HoneyPot.css.d.ts +1 -0
  100. package/dist/Forms/HoneyPot/HoneyPot.css.js +5 -0
  101. package/dist/Forms/HoneyPot/index.d.ts +23 -0
  102. package/dist/Forms/HoneyPot/index.js +69 -0
  103. package/dist/Forms/MortgageRate/MortgageRateForm.js +12 -5
  104. package/dist/Forms/MortgageRate/MortgageRateWatch.js +12 -5
  105. package/dist/Forms/MortgageWarehouseLending.d.ts +11 -0
  106. package/dist/Forms/MortgageWarehouseLending.js +343 -0
  107. package/dist/Forms/QuickPricer/QuickPricerForm.d.ts +1 -1
  108. package/dist/Forms/QuickPricer/QuickPricerForm.js +624 -609
  109. package/dist/Forms/SalesforceFieldsForm.d.ts +5 -0
  110. package/dist/Forms/SalesforceFieldsForm.js +11 -1
  111. package/dist/Forms/ScheduleCall.d.ts +1 -1
  112. package/dist/Forms/ScheduleCall.js +156 -134
  113. package/dist/Forms/ScheduleCallPremier.d.ts +1 -1
  114. package/dist/Forms/ScheduleCallPremier.js +178 -156
  115. package/dist/Forms/SuccesForm.js +16 -9
  116. package/dist/Forms/VendorQuestionnaire.d.ts +1 -1
  117. package/dist/Forms/VendorQuestionnaire.js +817 -795
  118. package/dist/Forms/WcplSurvey.d.ts +1 -1
  119. package/dist/Forms/WcplSurvey.js +112 -90
  120. package/dist/Forms/applynow-utils.d.ts +1 -0
  121. package/dist/Forms/applynow-utils.js +48 -0
  122. package/dist/Forms/index.d.ts +4 -0
  123. package/dist/Forms/index.js +14 -2
  124. package/dist/HeroBanner/HeroBanner.css.d.ts +2 -0
  125. package/dist/HeroBanner/HeroBanner.css.js +4 -0
  126. package/dist/HeroBanner/HeroBanner.d.ts +1 -1
  127. package/dist/HeroBanner/HeroBanner.interface.d.ts +3 -0
  128. package/dist/HeroBanner/HeroBanner.js +90 -3
  129. package/dist/HeroBanner/index.js +3 -1
  130. package/dist/Hyperlink/index.js +12 -5
  131. package/dist/IconBillboard/IconBillboard.css.d.ts +1 -0
  132. package/dist/IconBillboard/IconBillboard.css.js +2 -0
  133. package/dist/IconBillboard/IconBillboard.d.ts +1 -2
  134. package/dist/IconBillboard/IconBillboard.js +30 -85
  135. package/dist/IconBillboard/index.js +3 -3
  136. package/dist/IconBillboard/sections/CallToActionSection.d.ts +12 -0
  137. package/dist/IconBillboard/sections/CallToActionSection.js +102 -0
  138. package/dist/IconBillboard/sections/HeaderSection.d.ts +11 -0
  139. package/dist/IconBillboard/sections/HeaderSection.js +23 -0
  140. package/dist/IconBillboard/sections/IconSection.d.ts +7 -0
  141. package/dist/IconBillboard/sections/IconSection.js +18 -0
  142. package/dist/IconBillboard/sections/ItemsSection.d.ts +11 -0
  143. package/dist/IconBillboard/sections/ItemsSection.js +11 -0
  144. package/dist/IconBillboard/sections/LayoutSection.d.ts +8 -0
  145. package/dist/IconBillboard/sections/LayoutSection.js +6 -0
  146. package/dist/ImageBillboard/ExitIntentModal/useExitIntentModal.js +6 -1
  147. package/dist/ImageBillboard/ImageBillboard.interface.d.ts +7 -0
  148. package/dist/ImageBillboard/ImageBillboardSet.d.ts +1 -1
  149. package/dist/ImageBillboard/ImageBillboardSet.js +20 -4
  150. package/dist/ImageLink/ImageLink.js +12 -5
  151. package/dist/ImageLink/ImageLinkSet.js +15 -8
  152. package/dist/ImageLink/index.js +12 -5
  153. package/dist/Insight/Featured/CategorySelector.js +13 -6
  154. package/dist/Insight/Featured/Featured.js +20 -13
  155. package/dist/Insight/Featured/Header.js +19 -12
  156. package/dist/LandingPageHeader/LandingPageHeader.css.d.ts +2 -0
  157. package/dist/LandingPageHeader/LandingPageHeader.css.js +6 -2
  158. package/dist/LandingPageHeader/LandingPageHeader.js +18 -9
  159. package/dist/LandingPageHeader/index.js +3 -1
  160. package/dist/Modal/Modal.js +12 -5
  161. package/dist/NavigationMenu/AxosALTS/NavData.js +12 -5
  162. package/dist/NavigationMenu/AxosALTS/index.js +12 -5
  163. package/dist/NavigationMenu/AxosAdvisor/SubNavBar.js +3 -10
  164. package/dist/NavigationMenu/AxosAdvisor/index.js +3 -11
  165. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.d.ts +3 -4
  166. package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +29 -13
  167. package/dist/NavigationMenu/AxosBank/NavData.js +12 -5
  168. package/dist/NavigationMenu/AxosBank/SubNavBar.js +67 -63
  169. package/dist/NavigationMenu/AxosBank/index.js +12 -5
  170. package/dist/NavigationMenu/LaVictoire/NavData.js +12 -5
  171. package/dist/NavigationMenu/LaVictoire/index.js +12 -5
  172. package/dist/SetContainer/SetContainer.js +12 -5
  173. package/dist/SocialMediaBar/iconsRepository.js +12 -5
  174. package/dist/StepItemSet/StepItemSet.css.d.ts +1 -0
  175. package/dist/StepItemSet/StepItemSet.css.js +9 -5
  176. package/dist/StepItemSet/StepItemSet.d.ts +6 -0
  177. package/dist/StepItemSet/StepItemSet.js +22 -3
  178. package/dist/StepItemSet/index.js +2 -1
  179. package/dist/Table/Table.d.ts +1 -1
  180. package/dist/VideoTile/VideoTile.interface.d.ts +4 -3
  181. package/dist/VideoTile/VideoTile.js +189 -28
  182. package/dist/VideoWrapper/index.js +13 -6
  183. package/dist/WalnutIframe/wrapper.module.js +3 -3
  184. package/dist/assets/Calculators/AxosOneCalculator/BalanceAPYCalculator.css +12 -0
  185. package/dist/assets/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css +3 -0
  186. package/dist/assets/Chatbot/Bubble.css +51 -0
  187. package/dist/assets/Chatbot/ChatWindow.css +213 -0
  188. package/dist/assets/Comparison/Comparison.css +3 -1
  189. package/dist/assets/Forms/Forms.css +135 -105
  190. package/dist/assets/Forms/HoneyPot/HoneyPot.css +8 -0
  191. package/dist/assets/HeroBanner/HeroBanner.css +12 -0
  192. package/dist/assets/IconBillboard/IconBillboard.css +21 -1
  193. package/dist/assets/ImageBillboard/ImageBillboard.css +26 -15
  194. package/dist/assets/LandingPageHeader/LandingPageHeader.css +36 -3
  195. package/dist/assets/StepItemSet/StepItemSet.css +27 -10
  196. package/dist/assets/TopicalNavItem/TopicalNavItem.css +2 -2
  197. package/dist/assets/WalnutIframe/wrapper.css.css +7 -8
  198. package/dist/icons/Logos/SPB.d.ts +4 -0
  199. package/dist/icons/Logos/SPB.js +132 -0
  200. package/dist/icons/index.d.ts +1 -0
  201. package/dist/icons/index.js +2 -0
  202. package/dist/main.d.ts +1 -0
  203. package/dist/main.js +79 -23
  204. package/dist/utils/allowedAxosDomains.js +4 -2
  205. package/package.json +3 -1
@@ -0,0 +1,165 @@
1
+ "use client";
2
+ import { jsxs, jsx } from "react/jsx-runtime";
3
+ import { useRef, useEffect } from "react";
4
+ import { authenticate } from "./authenticate.js";
5
+ import { useMessages } from "./store/messages.js";
6
+ const companyId = process.env.CCAI_COMPANY_ID || "";
7
+ const tenant = process.env.CCAI_TENANT_NAME || "";
8
+ const host = process.env.CCAI_HOST || "";
9
+ const COBROWSE_CONSENT_TEMPLATE = `
10
+ <script class="cobrowse-template" type="text/template">
11
+ <div class="cobrowse">
12
+ <div class="cobrowse-title">$title</div>
13
+ <div class="cobrowse-content">$content</div>
14
+ <div class="cobrowse-footer">
15
+ <button class="cobrowse-deny js-cobrowse-deny">$deny</button>
16
+ <button class="cobrowse-allow js-cobrowse-allow">$allow</button>
17
+ </div>
18
+ </div>
19
+ <\/script>
20
+ `;
21
+ function Chat() {
22
+ const clientRef = useRef(null);
23
+ const hasLoadedBefore = useRef(true);
24
+ const addMessages = useMessages((state) => state.addMessages);
25
+ const addMessage = useMessages((state) => state.addMessage);
26
+ const chatRef = useRef(null);
27
+ const isMounted = useRef(true);
28
+ useEffect(() => {
29
+ let messageHandler;
30
+ let identityHandler;
31
+ let chatUpdatedHandler;
32
+ let memberJoinedHandler;
33
+ let chatConnectedHandler;
34
+ async function initChat() {
35
+ const { Client, consoleLoggerHandler, Logger } = await import("@ujet/websdk-headless");
36
+ console.log("this", isMounted);
37
+ Logger.addHandler(consoleLoggerHandler);
38
+ clientRef.current = new Client({
39
+ companyId,
40
+ tenant,
41
+ cobrowse: {
42
+ enabled: true,
43
+ template: COBROWSE_CONSENT_TEMPLATE,
44
+ messages: {
45
+ confirmSessionTitle: "...",
46
+ confirmSessionContent: "...",
47
+ endSessionText: "...",
48
+ confirmRemoteControlTitle: "...",
49
+ confirmRemoteControlContent: "...",
50
+ confirmFullDeviceTitle: "...",
51
+ confirmFullDeviceContent: "...",
52
+ allowText: "...",
53
+ denyText: "..."
54
+ }
55
+ },
56
+ host,
57
+ authenticate
58
+ });
59
+ const menus = await clientRef.current?.getMenus();
60
+ try {
61
+ chatRef.current = await clientRef.current?.loadOngoingChat();
62
+ console.log("chat:", chatRef.current);
63
+ if (!chatRef.current) {
64
+ chatRef.current = await clientRef.current?.createChat(
65
+ menus?.menus[5].id
66
+ );
67
+ }
68
+ } catch (error) {
69
+ console.error("Error creating chat:", error);
70
+ chatRef.current = await clientRef.current?.createChat(
71
+ menus?.menus[5].id
72
+ );
73
+ }
74
+ console.log("this");
75
+ identityHandler = (identity) => {
76
+ if (!isMounted.current) return;
77
+ console.log("identity:", identity);
78
+ };
79
+ messageHandler = (msg) => {
80
+ console.log("new message:", msg);
81
+ console.log("addMessage:", msg);
82
+ addMessage(msg);
83
+ };
84
+ chatUpdatedHandler = (chat) => {
85
+ console.log("chat updated:", chat);
86
+ };
87
+ chatConnectedHandler = async () => {
88
+ console.log("connected");
89
+ const messagesFetched = await clientRef.current?.fetchMessages();
90
+ console.log("[messages]:", messagesFetched);
91
+ addMessages(messagesFetched || []);
92
+ };
93
+ memberJoinedHandler = (identity) => {
94
+ console.log("member joined:", identity);
95
+ };
96
+ console.log(isMounted.current);
97
+ clientRef.current?.on("authenticated", () => {
98
+ console.log("authenticated");
99
+ });
100
+ clientRef.current?.on("chat.ongoing", (chat) => {
101
+ if (!isMounted.current) return;
102
+ console.log("chat:", chat);
103
+ });
104
+ clientRef.current?.on("chat.connected", chatConnectedHandler);
105
+ clientRef.current?.on("chat.updated", chatUpdatedHandler);
106
+ clientRef.current?.on("chat.identity", identityHandler);
107
+ clientRef.current?.on("chat.message", messageHandler);
108
+ clientRef.current?.on("cobrowse.request", ({ from }) => {
109
+ console.log("request by", from);
110
+ });
111
+ clientRef.current?.on("chat.memberJoined", memberJoinedHandler);
112
+ }
113
+ if (hasLoadedBefore.current) {
114
+ console.log("Initial setup");
115
+ initChat();
116
+ hasLoadedBefore.current = false;
117
+ }
118
+ return () => {
119
+ isMounted.current = false;
120
+ console.log("Component unmounted. Cancelling pending async operations.");
121
+ if (clientRef.current) {
122
+ if (messageHandler)
123
+ clientRef.current.off("chat.message", messageHandler);
124
+ if (identityHandler)
125
+ clientRef.current.off("chat.identity", identityHandler);
126
+ clientRef.current.off("chat.connected", chatConnectedHandler);
127
+ clientRef.current.off("chat.updated", chatUpdatedHandler);
128
+ clientRef.current.off("chat.memberJoined", memberJoinedHandler);
129
+ if (typeof clientRef.current.destroyChat === "function") {
130
+ console.log("Destroying chat:", chatRef.current);
131
+ clientRef.current.destroyChat();
132
+ }
133
+ }
134
+ };
135
+ }, [addMessage, addMessages]);
136
+ return /* @__PURE__ */ jsxs("div", { children: [
137
+ /* @__PURE__ */ jsx("h2", { children: "Chat" }),
138
+ /* @__PURE__ */ jsxs(
139
+ "form",
140
+ {
141
+ style: { marginTop: "1rem", display: "flex", gap: "0.5rem" },
142
+ onSubmit: async (e) => {
143
+ e.preventDefault();
144
+ const form = e.target;
145
+ const input = form.elements[0];
146
+ const message = input.value;
147
+ console.log("Sending message:", message);
148
+ try {
149
+ await clientRef.current?.sendTextMessage(message);
150
+ input.value = "";
151
+ } catch (error) {
152
+ console.error("Error sending message:", error);
153
+ }
154
+ },
155
+ children: [
156
+ /* @__PURE__ */ jsx("input", { type: "text", name: "message", placeholder: "Type a message..." }),
157
+ /* @__PURE__ */ jsx("button", { type: "submit", children: "Send" })
158
+ ]
159
+ }
160
+ )
161
+ ] });
162
+ }
163
+ export {
164
+ Chat as default
165
+ };
@@ -0,0 +1,18 @@
1
+ export declare const windowStyle: string;
2
+ export declare const windowOpenStyle: string;
3
+ export declare const windowBarStyle: string;
4
+ export declare const chat_title: string;
5
+ export declare const button_reset: string;
6
+ export declare const arrowFill: string;
7
+ export declare const inputStyle: string;
8
+ export declare const sendButtonStyle: string;
9
+ export declare const messagesContainerStyle: string;
10
+ export declare const notificationStyle: string;
11
+ export declare const messageStyle: string;
12
+ export declare const inline_button_wrapper: string;
13
+ export declare const inline_button: string;
14
+ export declare const endChatButtonStyle: string;
15
+ export declare const chatbotMenu: string;
16
+ export declare const chatbotMenuItem: string;
17
+ export declare const chatNetworkStatus: string;
18
+ export declare const chatFinishDialog: string;
@@ -0,0 +1,39 @@
1
+ import '../assets/Chatbot/ChatWindow.css';/* empty css */
2
+ var windowStyle = "_13n1jqk0";
3
+ var windowOpenStyle = "_13n1jqk1";
4
+ var windowBarStyle = "_13n1jqk2";
5
+ var chat_title = "_13n1jqk3";
6
+ var button_reset = "_13n1jqk4";
7
+ var arrowFill = "_13n1jqk5";
8
+ var inputStyle = "_13n1jqk6";
9
+ var sendButtonStyle = "_13n1jqk7";
10
+ var messagesContainerStyle = "_13n1jqk8";
11
+ var notificationStyle = "_13n1jqk9";
12
+ var messageStyle = "_13n1jqka";
13
+ var inline_button_wrapper = "_13n1jqkb";
14
+ var inline_button = "_13n1jqkc";
15
+ var endChatButtonStyle = "_13n1jqkd";
16
+ var chatbotMenu = "_13n1jqke";
17
+ var chatbotMenuItem = "_13n1jqkf";
18
+ var chatNetworkStatus = "_13n1jqkg";
19
+ var chatFinishDialog = "_13n1jqkh";
20
+ export {
21
+ arrowFill,
22
+ button_reset,
23
+ chatFinishDialog,
24
+ chatNetworkStatus,
25
+ chat_title,
26
+ chatbotMenu,
27
+ chatbotMenuItem,
28
+ endChatButtonStyle,
29
+ inline_button,
30
+ inline_button_wrapper,
31
+ inputStyle,
32
+ messageStyle,
33
+ messagesContainerStyle,
34
+ notificationStyle,
35
+ sendButtonStyle,
36
+ windowBarStyle,
37
+ windowOpenStyle,
38
+ windowStyle
39
+ };
@@ -0,0 +1,26 @@
1
+ import { MessageResponse as BaseMessageResponse, HumanAgent, VirtualAgent } from '@ujet/websdk-headless';
2
+ import { default as React } from 'react';
3
+
4
+ interface MessageResponse extends BaseMessageResponse {
5
+ to_agent?: HumanAgent;
6
+ }
7
+ export interface ChatBubble {
8
+ id: string | number;
9
+ body: string;
10
+ sender?: string;
11
+ timestamp?: string;
12
+ isOwn?: boolean;
13
+ }
14
+ interface ChatWindowProps {
15
+ messages: MessageResponse[];
16
+ status?: string;
17
+ onSend: (msg: string) => void;
18
+ inputDisabled?: boolean;
19
+ onClose?: () => void;
20
+ endChat?: () => void;
21
+ showReconnect?: boolean;
22
+ virtualAgent?: VirtualAgent | null;
23
+ showAvatar?: boolean;
24
+ }
25
+ export declare const ChatWindow: React.FC<ChatWindowProps>;
26
+ export {};
@@ -0,0 +1,446 @@
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" || messages.length == 0 || 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() || messages.length == 0 || escalationDeflected,
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
+ };