@meetelise/chat 1.21.0 → 1.21.2

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 (76) hide show
  1. package/.github/pull_request_template.md +61 -0
  2. package/.idea/codeStyles/Project.xml +57 -0
  3. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  4. package/.idea/inspectionProfiles/Project_Default.xml +6 -0
  5. package/.idea/vcs.xml +6 -0
  6. package/.idea/workspace.xml +67 -0
  7. package/README.md +29 -14
  8. package/declarations.d.ts +12 -0
  9. package/package.json +5 -1
  10. package/public/demo/index.html +62 -4
  11. package/public/demo/secret.html +63 -0
  12. package/public/dist/index.js +3184 -1105
  13. package/public/dist/index.js.LICENSE.txt +19 -9
  14. package/public/index.html +6 -4
  15. package/src/MEChat.ts +207 -52
  16. package/src/MyPubnub.ts +657 -0
  17. package/src/WebComponent/LeadSourceClient.ts +300 -0
  18. package/src/WebComponent/Scheduler/date-picker.ts +1 -1
  19. package/src/WebComponent/Scheduler/time-picker.ts +86 -76
  20. package/src/WebComponent/Scheduler/tour-scheduler.ts +694 -764
  21. package/src/WebComponent/Scheduler/tour-type-option.ts +17 -3
  22. package/src/WebComponent/Scheduler/tourSchedulerStyles.ts +418 -0
  23. package/src/WebComponent/actions/InputStyles.ts +32 -10
  24. package/src/WebComponent/actions/action-confirm-button.ts +16 -11
  25. package/src/WebComponent/actions/call-us-window.ts +341 -58
  26. package/src/WebComponent/actions/details-window.ts +30 -16
  27. package/src/WebComponent/actions/email-us-window.ts +89 -58
  28. package/src/WebComponent/actions/formatPhoneNumber.ts +15 -1
  29. package/src/WebComponent/actions/minimize-expand-button.ts +92 -0
  30. package/src/WebComponent/health-chat.ts +267 -0
  31. package/src/WebComponent/healthcare/healthcare-launcher-styles.ts +34 -0
  32. package/src/WebComponent/healthcare/healthcare-launcher.ts +100 -0
  33. package/src/WebComponent/healthchat-styles.ts +119 -0
  34. package/src/WebComponent/index.ts +1 -1
  35. package/src/WebComponent/launcher/Launcher.ts +919 -0
  36. package/src/WebComponent/{launcherStyles.ts → launcher/launcherStyles.ts} +172 -29
  37. package/src/WebComponent/launcher/mobile-launcher.ts +127 -0
  38. package/src/WebComponent/launcher/typeEmojiStyles.ts +161 -0
  39. package/src/WebComponent/launcher/typeMiniStyles.ts +60 -0
  40. package/src/WebComponent/launcher/typeMobileStyles.ts +50 -0
  41. package/src/WebComponent/leasing-chat-styles.ts +114 -0
  42. package/src/WebComponent/me-chat.ts +964 -351
  43. package/src/WebComponent/me-select.ts +48 -21
  44. package/src/WebComponent/mini-loader.ts +28 -0
  45. package/src/WebComponent/pubnub-chat-styles.ts +192 -0
  46. package/src/WebComponent/pubnub-chat.ts +707 -0
  47. package/src/WebComponent/pubnub-media.ts +208 -0
  48. package/src/WebComponent/pubnub-message-styles.ts +54 -0
  49. package/src/WebComponent/pubnub-message.ts +421 -0
  50. package/src/analytics.ts +114 -14
  51. package/src/assetUrls.ts +2 -0
  52. package/src/disclaimers.ts +56 -0
  53. package/src/fetchBuildingABTestType.ts +4 -0
  54. package/src/fetchBuildingInfo.ts +25 -17
  55. package/src/fetchFeatureFlag.ts +147 -0
  56. package/src/fetchLeadSources.ts +67 -1
  57. package/src/fetchPhoneNumberFromSource.ts +31 -0
  58. package/src/fetchWebchatPreferences.ts +55 -0
  59. package/src/getAvailabilities.ts +7 -3
  60. package/src/getBuildingPhoneNumber.ts +26 -0
  61. package/src/getShouldAllowScheduling.ts +16 -0
  62. package/src/getTimezoneString.ts +39 -0
  63. package/src/gtm.ts +17 -0
  64. package/src/handleChatId.ts +101 -0
  65. package/src/insertDNIIntoWebsite.ts +136 -0
  66. package/src/insertLeadSourceIntoSchedulerLinks.ts +50 -0
  67. package/src/postLeadSources.ts +39 -35
  68. package/src/svgIcons.ts +62 -53
  69. package/src/themes.ts +47 -121
  70. package/src/utils.ts +88 -1
  71. package/src/WebComponent/Launcher.ts +0 -559
  72. package/src/WebComponent/actions/text-us-window.ts +0 -279
  73. package/src/chatID.ts +0 -64
  74. package/src/createConversation.ts +0 -57
  75. package/src/fetchCurrentParsedLeadSource.ts +0 -24
  76. package/src/getRegisteredPhoneNumbers.ts +0 -56
@@ -0,0 +1,267 @@
1
+ import { css, html, LitElement, TemplateResult } from "lit";
2
+ import { customElement, property, state } from "lit/decorators.js";
3
+ import { createRef, Ref } from "lit/directives/ref.js";
4
+ import { Launcher } from "./launcher/Launcher";
5
+ import "./Scheduler/tour-scheduler";
6
+ import { installLauncher } from "./launcher/Launcher";
7
+
8
+ import "./MEChat.css";
9
+ import MyPubnub from "../MyPubnub";
10
+
11
+ import "./actions/minimize-expand-button";
12
+ import "./launcher/mobile-launcher";
13
+ import "./pubnub-chat";
14
+ import {
15
+ clearChatStorageKey,
16
+ createChatStorageKey,
17
+ getChatStorageKey,
18
+ isChatKeyValid,
19
+ } from "../handleChatId";
20
+ import { isMobile } from "../utils";
21
+ import "./healthcare/healthcare-launcher";
22
+
23
+ @customElement("health-chat")
24
+ export class HealthChat extends LitElement {
25
+ static styles = css`
26
+ :host {
27
+ all: initial;
28
+ }
29
+
30
+ #__talkjs_launcher:not(.shouldBeVisible) {
31
+ display: none;
32
+ }
33
+
34
+ .launcherContainer.launcher__mobile {
35
+ width: 100%;
36
+ height: 100px;
37
+ }
38
+
39
+ #typeMobile-bttn {
40
+ position: fixed;
41
+ right: 24px;
42
+ bottom: 24px;
43
+ width: 80px;
44
+ height: 80px;
45
+
46
+ border: 2px solid #f3f6fc;
47
+ border-radius: 1000px;
48
+
49
+ display: flex;
50
+ justify-content: center;
51
+ align-items: center;
52
+ margin-right: 40px;
53
+ }
54
+ #typeMobile-bttn:hover > #typeMobile-inner {
55
+ background: #eaecf4;
56
+ cursor: pointer;
57
+ }
58
+ #typeMobile-bttn > #typeMobile-inner {
59
+ width: 72px;
60
+ height: 72px;
61
+
62
+ background: #ffffff;
63
+ border: 2px solid #f3f6fc;
64
+ border-radius: 1000px;
65
+
66
+ display: flex;
67
+ justify-content: center;
68
+ align-items: center;
69
+ gap: 4px;
70
+ }
71
+ #typeMobile-txt {
72
+ font-family: Poppins, "Open Sans", "Helvetica", sans-serif;
73
+ box-sizing: border-box;
74
+ font-weight: 300;
75
+ line-height: 150%;
76
+ font-size: 16px;
77
+ }
78
+ `;
79
+
80
+ @property({ type: String })
81
+ private healthcareId = "";
82
+
83
+ @property({ type: Number })
84
+ private right = 0;
85
+
86
+ @property({ type: Number })
87
+ private bottom = 0;
88
+
89
+ @property({ type: Number })
90
+ private top = 0;
91
+
92
+ @property({ type: Number })
93
+ private left = 0;
94
+
95
+ @state()
96
+ private launcher: HTMLElement | null = null;
97
+
98
+ @state()
99
+ private currentLeadSource: string | null = null;
100
+
101
+ @state()
102
+ private displayPubnubChat = false;
103
+
104
+ @state()
105
+ private myPubnub: MyPubnub | null = null;
106
+
107
+ @state()
108
+ private requiresConsent = false;
109
+
110
+ @state()
111
+ private privacyPolicyUrl = "http://bit.ly/me_privacy_policy";
112
+
113
+ @state()
114
+ private isLoading = true;
115
+
116
+ launcherRef: Ref<Launcher> = createRef();
117
+
118
+ firstUpdated = async (): Promise<void> => {
119
+ const isInMaintenanceMode = false; // TODO: check
120
+ if (isInMaintenanceMode) {
121
+ // eslint-disable-next-line no-console
122
+ console.warn(
123
+ "MeetElise Chat is in maintenance mode. Chat icon will not appear."
124
+ );
125
+ return;
126
+ }
127
+ await this.initializeChatVariables();
128
+ };
129
+
130
+ private initializeChatVariables = async (): Promise<void> => {
131
+ this.isLoading = true;
132
+
133
+ // important to distinguish between a user who has never opened the chat and a user who has opened the chat but closed it
134
+ const currentChatStorageKey = getChatStorageKey(this.healthcareId);
135
+ const updatedChatStorageKey = isChatKeyValid(
136
+ this.healthcareId,
137
+ currentChatStorageKey
138
+ )
139
+ ? currentChatStorageKey
140
+ : createChatStorageKey(this.healthcareId, false);
141
+
142
+ if (!updatedChatStorageKey.leadId) {
143
+ throw new Error("Lead ID is null");
144
+ }
145
+
146
+ this.myPubnub = new MyPubnub(
147
+ this.healthcareId,
148
+ null,
149
+ "",
150
+ this.currentLeadSource,
151
+ updatedChatStorageKey.leadId
152
+ );
153
+
154
+ if (updatedChatStorageKey.initiatedChat) {
155
+ await this.myPubnub.initializePubnub(currentChatStorageKey);
156
+ }
157
+
158
+ if (!isMobile()) {
159
+ this.displayPubnubChat = true;
160
+ }
161
+
162
+ this.attachOnClickToLauncher();
163
+
164
+ this.isLoading = false;
165
+ };
166
+
167
+ public async restartConversation(): Promise<void> {
168
+ this.myPubnub?.handleDisconnect();
169
+ clearChatStorageKey(this.healthcareId);
170
+ this.myPubnub = null;
171
+ this.displayPubnubChat = false;
172
+ await this.initializeChatVariables();
173
+ }
174
+
175
+ /** Show the chat button on the screen if it was previously hidden. */
176
+ show(): void {
177
+ if (!this.launcher) {
178
+ return;
179
+ }
180
+ this.launcher.style.display = "";
181
+ }
182
+
183
+ /** Hide the chat button from the screen (but don't remove from the DOM). */
184
+ hide(): void {
185
+ if (!this.launcher) {
186
+ return;
187
+ }
188
+ this.launcher.style.display = "none";
189
+ }
190
+
191
+ disconnectedCallback(): void {
192
+ this.myPubnub?.handleDisconnect();
193
+ super.disconnectedCallback();
194
+ }
195
+
196
+ private attachOnClickToLauncher = () => {
197
+ const launcher = this.launcherRef.value;
198
+ if (!launcher) {
199
+ return;
200
+ }
201
+ launcher.onChatTapped = async () => {
202
+ this.displayPubnubChat = true;
203
+ };
204
+ };
205
+
206
+ render(): TemplateResult {
207
+ installLauncher();
208
+
209
+ if (this.isLoading) return html``;
210
+ return html`
211
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
212
+ <div id="aria-describe-info" style="display: none;">
213
+ EliseAI widget that allows you to chat with a virtual assistant, book
214
+ a tour, contact the leasing office, and more.
215
+ </div>
216
+ ${
217
+ this.displayPubnubChat
218
+ ? html`
219
+ <pubnub-chat
220
+ id="pubnub-chat"
221
+ .isHealthChat=${true}
222
+ .channel=${this.myPubnub?.channel}
223
+ .myPubnub=${this.myPubnub}
224
+ .buildingSlug=${this.healthcareId}
225
+ .onClickExit=${() => {
226
+ this.displayPubnubChat = false;
227
+ }}
228
+ .requiresConsent=${this.requiresConsent}
229
+ .privacyPolicyUrl=${this.privacyPolicyUrl}
230
+ .top=${this.top}
231
+ .bottom=${this.bottom}
232
+ .left=${this.left}
233
+ .right=${this.right}
234
+ ></pubnub-chat>
235
+ `
236
+ : html``
237
+ }
238
+ <healthcare-launcher
239
+ id="healthcare-launcher"
240
+ .top=${this.top}
241
+ .bottom=${this.bottom}
242
+ .left=${this.left}
243
+ .right=${this.right}
244
+ .isChatOpen=${this.displayPubnubChat}
245
+ .onClickCloseChat=${() => {
246
+ this.displayPubnubChat = false;
247
+ }}
248
+ .onClickOpenChat=${() => {
249
+ this.displayPubnubChat = true;
250
+ }}
251
+
252
+ ></healthcare-launcher>
253
+
254
+ </meta>
255
+ `;
256
+ }
257
+ }
258
+
259
+ declare global {
260
+ interface HTMLElementTagNameMap {
261
+ "health-chat": HealthChat;
262
+ }
263
+
264
+ interface Window {
265
+ RCTPCampaign?: { CampaignDetails: { Source: string } };
266
+ }
267
+ }
@@ -0,0 +1,34 @@
1
+ import { css } from "lit";
2
+
3
+ export const healthcareLauncherStyles = css`
4
+ .chat-launcher {
5
+ position: fixed;
6
+ }
7
+ .close-chat-bttn,
8
+ .open-chat-bttn {
9
+ width: 48px;
10
+ height: 48px;
11
+ border-radius: 100%;
12
+ background: linear-gradient(
13
+ 180deg,
14
+ rgba(96, 50, 230, 1) 29%,
15
+ rgba(140, 88, 229, 1) 63%
16
+ );
17
+
18
+ display: flex;
19
+ justify-content: center;
20
+ align-items: center;
21
+
22
+ box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
23
+ transition: all 0.2s ease-in-out;
24
+ }
25
+
26
+ .close-chat-bttn,
27
+ .open-chat-bttn {
28
+ border: none;
29
+ &:hover {
30
+ cursor: pointer;
31
+ filter: brightness(1.1);
32
+ }
33
+ }
34
+ `;
@@ -0,0 +1,100 @@
1
+ import { html, LitElement, TemplateResult } from "lit";
2
+ import { customElement, property } from "lit/decorators.js";
3
+ import { styleMap } from "lit/directives/style-map.js";
4
+ import { isMobile } from "../../utils";
5
+ import { healthcareLauncherStyles } from "./healthcare-launcher-styles";
6
+
7
+ @customElement("healthcare-launcher")
8
+ export class HealthcareLauncher extends LitElement {
9
+ static styles = [healthcareLauncherStyles];
10
+
11
+ @property({ type: Number })
12
+ private right = 0;
13
+
14
+ @property({ type: Number })
15
+ private bottom = 0;
16
+
17
+ @property({ type: Number })
18
+ private top = 0;
19
+
20
+ @property({ type: Number })
21
+ private left = 0;
22
+
23
+ @property({ attribute: true })
24
+ isChatOpen = false;
25
+
26
+ @property({ attribute: true })
27
+ onClickCloseChat: () => void = () => ({});
28
+
29
+ @property({ attribute: true })
30
+ onClickOpenChat: () => void = () => ({});
31
+
32
+ render(): TemplateResult {
33
+ if (this.isChatOpen) {
34
+ return html`
35
+ <div
36
+ class="chat-launcher"
37
+ style=${styleMap({
38
+ top:
39
+ !isMobile() && !isNaN(this.top)
40
+ ? `${this.top + 432}px`
41
+ : undefined,
42
+ bottom:
43
+ !isMobile() && !isNaN(this.bottom)
44
+ ? `${this.bottom - 60}px`
45
+ : "72px",
46
+ left:
47
+ !isMobile() && !isNaN(this.left) ? `${this.left}px` : undefined,
48
+ right:
49
+ !isMobile() && !isNaN(this.right) ? `${this.right}px` : "18px",
50
+ })}
51
+ >
52
+ <button class="close-chat-bttn" @click=${this.onClickCloseChat}>
53
+ <svg
54
+ width="16"
55
+ height="10"
56
+ viewBox="0 0 16 10"
57
+ fill="none"
58
+ xmlns="http://www.w3.org/2000/svg"
59
+ >
60
+ <path
61
+ d="M2 2L8 8L14 2"
62
+ stroke="white"
63
+ stroke-width="1.5"
64
+ stroke-linecap="square"
65
+ />
66
+ </svg>
67
+ </button>
68
+ </div>
69
+ `;
70
+ }
71
+ return html` <div
72
+ class="chat-launcher"
73
+ style=${styleMap({
74
+ top:
75
+ !isMobile() && !isNaN(this.top) ? `${this.top + 432}px` : undefined,
76
+ bottom:
77
+ !isMobile() && !isNaN(this.bottom) ? `${this.bottom - 60}px` : "72px",
78
+ left: !isMobile() && !isNaN(this.left) ? `${this.left}px` : undefined,
79
+ right: !isMobile() && !isNaN(this.right) ? `${this.right}px` : "18px",
80
+ })}
81
+ >
82
+ <button class="open-chat-bttn" @click=${this.onClickOpenChat}>
83
+ <svg
84
+ width="24"
85
+ height="24"
86
+ viewBox="0 0 24 24"
87
+ fill="none"
88
+ xmlns="http://www.w3.org/2000/svg"
89
+ >
90
+ <path
91
+ fill-rule="evenodd"
92
+ clip-rule="evenodd"
93
+ d="M11.9955 2.40005C17.2974 2.40005 21.5955 6.69812 21.5955 12.0001C21.5955 17.302 17.2974 21.6001 11.9955 21.6001C10.2662 21.6001 8.64362 21.1428 7.24219 20.3426C7.15808 20.2946 7.05854 20.2806 6.96499 20.3056L3.09414 21.3428C2.82646 21.4146 2.58151 21.1696 2.65324 20.9019L3.69036 17.0313C3.71543 16.9378 3.70145 16.8382 3.65341 16.7541C2.85293 15.3525 2.39551 13.7297 2.39551 12.0001C2.39551 6.69812 6.69357 2.40005 11.9955 2.40005ZM8.20315 13.0047C8.73335 13.0047 9.16315 12.5749 9.16315 12.0447C9.16315 11.5146 8.73335 11.0848 8.20315 11.0848C7.67296 11.0848 7.24315 11.5146 7.24315 12.0447C7.24315 12.5749 7.67296 13.0047 8.20315 13.0047ZM13.0033 12.0447C13.0033 12.5749 12.5735 13.0047 12.0433 13.0047C11.5131 13.0047 11.0833 12.5749 11.0833 12.0447C11.0833 11.5146 11.5131 11.0848 12.0433 11.0848C12.5735 11.0848 13.0033 11.5146 13.0033 12.0447ZM15.8822 13.0046C16.4124 13.0046 16.8422 12.5749 16.8422 12.0447C16.8422 11.5145 16.4124 11.0848 15.8822 11.0848C15.352 11.0848 14.9222 11.5145 14.9222 12.0447C14.9222 12.5749 15.352 13.0046 15.8822 13.0046Z"
94
+ fill="white"
95
+ />
96
+ </svg>
97
+ </button>
98
+ </div>`;
99
+ }
100
+ }
@@ -0,0 +1,119 @@
1
+ import { css } from "lit";
2
+
3
+ export const healthChatStyles = css`
4
+ #healthchat-container {
5
+ position: fixed;
6
+
7
+ z-index: 100001;
8
+ display: flex;
9
+ align-items: center;
10
+
11
+ display: flex;
12
+ flex-direction: column;
13
+ overflow: hidden;
14
+ box-shadow: -10px 60px 60px 0px #bfbfbf4d;
15
+
16
+ box-shadow: 0px 1px 24px 0px #0000001a;
17
+
18
+ font-family: Poppins, "Open Sans", "Helvetica", sans-serif;
19
+ }
20
+ .healthchat-container__desktop {
21
+ width: 300px;
22
+ height: 420px;
23
+ border-radius: 10px;
24
+ }
25
+
26
+ #healthchat-header {
27
+ height: 60px;
28
+ width: 100%;
29
+ background: white;
30
+ overflow: hidden;
31
+
32
+ box-sizing: border-box;
33
+
34
+ display: flex;
35
+ align-items: center;
36
+ padding: 24px 16px;
37
+ justify-content: space-between;
38
+ }
39
+
40
+ #healthchat-header-subtext {
41
+ font-family: Helvetica;
42
+ font-size: 8px;
43
+ font-weight: 300;
44
+ line-height: 11px;
45
+ letter-spacing: 0em;
46
+ text-align: left;
47
+ color: #737373;
48
+ }
49
+
50
+ .healthcare-conversation-body-backdrop {
51
+ background: #f1f2f4;
52
+ }
53
+
54
+ @media screen and (max-width: 767px) {
55
+ #conversation-body {
56
+ background: #efefef;
57
+ backdrop-filter: none;
58
+ }
59
+ }
60
+
61
+ .healthcare-disclaimer-inner {
62
+ width: 190px;
63
+ margin: 0 auto;
64
+ }
65
+ .healthcare-disclaimer-message {
66
+ font-size: 8px;
67
+ color: #737373;
68
+ line-height: 12px;
69
+ font-weight: 400;
70
+ text-align: center;
71
+ }
72
+ .healthcare-disclaimer-inner > a {
73
+ color: #737373;
74
+ }
75
+
76
+ #healthcare-footer {
77
+ min-height: 60px;
78
+ width: 100%;
79
+ background: white;
80
+ z-index: 100001;
81
+ }
82
+ #healthcare-inner-footer {
83
+ display: flex;
84
+ align-items: center;
85
+ justify-content: space-between;
86
+ box-sizing: border-box;
87
+ padding: 16px;
88
+ gap: 0px;
89
+ }
90
+ #healthcare-inner-footer > #message-input {
91
+ width: 100%;
92
+ max-height: 100px;
93
+ overflowy: auto;
94
+
95
+ font-family: inherit;
96
+ box-sizing: border-box;
97
+ font-weight: light;
98
+ border: none;
99
+ color: black;
100
+ background: none;
101
+
102
+ padding-right: 6px; /* width of the scrollbar */
103
+ box-sizing: border-box;
104
+ z-index: 1000000000000000000000000001;
105
+ }
106
+ #healthcare-inner-footer > #message-input:focus {
107
+ outline: none;
108
+ -webkit-box-shadow: none;
109
+ box-shadow: none;
110
+ }
111
+ #healthcare-send-message-bttn {
112
+ background: none;
113
+ border: none;
114
+ cursor: pointer;
115
+ }
116
+ .health-bttn-allow-access {
117
+ padding-right: 28px;
118
+ }
119
+ `;
@@ -1,2 +1,2 @@
1
- export { Launcher } from "./Launcher";
1
+ export { Launcher } from "./launcher/Launcher";
2
2
  import "./me-chat";