pager-widget 1.0.3 → 1.0.4

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 (71) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.js +4 -4
  3. package/dist/react-parcel.9f367d21.css +2 -18
  4. package/dist/react-parcel.9f367d21.css.map +1 -1
  5. package/dist/react-parcel.js +119 -214
  6. package/dist/react-parcel.js.map +1 -1
  7. package/out/AgentFeedbackButtonWrapper.js +15 -0
  8. package/out/App.js +28 -0
  9. package/out/BotMain.js +91 -0
  10. package/out/ButtonsWrapper.js +29 -0
  11. package/out/ChatPage.js +9 -0
  12. package/out/ChatPageContent.js +131 -0
  13. package/out/ChatPageHeader.js +267 -0
  14. package/out/ChatPageInput.js +29 -0
  15. package/out/ChatWidget.js +17 -0
  16. package/out/Consent.js +66 -0
  17. package/out/CountryDropdown.js +31 -0
  18. package/out/Form.js +238 -0
  19. package/out/HomePage.js +11 -0
  20. package/out/HomePageContent.js +32 -0
  21. package/out/HomePageFooter.js +87 -0
  22. package/out/HomePageHeader.js +66 -0
  23. package/out/InputField.js +80 -0
  24. package/out/Markdown.js +126 -0
  25. package/out/Message.js +197 -0
  26. package/out/MessagesT.js +2 -0
  27. package/out/NewRecentMessagePage.js +525 -0
  28. package/out/NewRecentMessageTab.js +23 -0
  29. package/out/ReceivedMessage.js +211 -0
  30. package/out/RecentMessageDetail.js +178 -0
  31. package/out/RecentMessageList.js +112 -0
  32. package/out/RecentMessageListCard.js +20 -0
  33. package/out/RecentMessageListHeader.js +156 -0
  34. package/out/RecentMessagePage.js +183 -0
  35. package/out/RecentMessageTab.js +35 -0
  36. package/out/WidgetMessage.js +14 -0
  37. package/out/WidgetToggleButton.js +191 -0
  38. package/out/WidgetType.js +2 -0
  39. package/out/assets/icons/pikaicons-react.js +17475 -0
  40. package/out/components/ConsentForm.js +7 -0
  41. package/out/components/CustomTooltip.js +34 -0
  42. package/out/hooks/useChatHistoryExists.js +32 -0
  43. package/out/hooks/useChatHistoryListExist.js +81 -0
  44. package/out/hooks/useChatScroll.js +14 -0
  45. package/out/hooks/useCurrentConversationExists.js +88 -0
  46. package/out/hooks/useInitialMessage.js +33 -0
  47. package/out/hooks/useMessage.js +230 -0
  48. package/out/hooks/useMessageReceiver.js +183 -0
  49. package/out/hooks/usePopupAnimation.js +20 -0
  50. package/out/hooks/useSocket.js +19 -0
  51. package/out/hooks/useSocketContext.js +81 -0
  52. package/out/hooks/useWidgetDimension.js +41 -0
  53. package/out/hooks/useWidgetToggle.js +22 -0
  54. package/out/index.js +31 -0
  55. package/out/markdown/CodeCopy.js +22 -0
  56. package/out/markdown/CodeHighlight.js +58 -0
  57. package/out/markdown/PagerMarkdown.js +36 -0
  58. package/out/markdown/pager_md.js +152 -0
  59. package/out/onscreenNotificationPopup.js +23 -0
  60. package/out/socket.js +11 -0
  61. package/out/utils/checkConversationExit.js +24 -0
  62. package/out/utils/convertTime.js +43 -0
  63. package/out/utils/sendInitialMessage.js +82 -0
  64. package/out/widget.js +21 -0
  65. package/out/widgetConfigStore.js +205 -0
  66. package/out/widgetConfigStore2.js +569 -0
  67. package/out/widgetControlstore.js +23 -0
  68. package/out/widgetStateHandler.js +106 -0
  69. package/out/widgetStore.js +171 -0
  70. package/out/widgetUserStore.js +47 -0
  71. package/package.json +1 -1
@@ -0,0 +1,525 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.NewRecentMessagePage = void 0;
40
+ const jsx_runtime_1 = require("react/jsx-runtime");
41
+ const react_1 = __importStar(require("react"));
42
+ const ReceivedMessage_1 = require("./ReceivedMessage");
43
+ const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
44
+ // import { useChatHistoryExists } from './hooks/useChatHistoryExists'
45
+ const pager_md_1 = __importDefault(require("./markdown/pager_md"));
46
+ const widgetConfigStore2_1 = require("./widgetConfigStore2");
47
+ const widgetStore_1 = require("./widgetStore");
48
+ const useCurrentConversationExists_1 = require("./hooks/useCurrentConversationExists");
49
+ // type MessageType = {
50
+ // type: string
51
+ // time: Date
52
+ // message: {
53
+ // event_id: string
54
+ // input?: string
55
+ // output: any[]
56
+ // context: Record<string, any>
57
+ // system: Record<string, any>
58
+ // }
59
+ // }
60
+ const NewRecentMessagePage = ({ toggleWidget, isExpanded, }) => {
61
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
62
+ // const { recentChat } = useChatHistoryExists()
63
+ // const [isSubmittedFormOpen, setIsSubmittedFormOpen] =
64
+ // useState<boolean>(true)
65
+ // const chatValues = recentChat ?? {}
66
+ // const widgetId = widget?.data?.id
67
+ // const messageResponse: MessageType[] = chatValues?.[widgetId] ?? []
68
+ const { recentConversation } = (0, useCurrentConversationExists_1.useSelectedConversation)();
69
+ const messageResponse = recentConversation != null
70
+ ? recentConversation.events.filter((e) => e.type === 'received' || e.type === 'sent')
71
+ : [];
72
+ const expandRef = react_1.default.useRef(null);
73
+ const [expandPopupOpen, setExpandPopupOpen] = react_1.default.useState(false);
74
+ const [showExpandPopUp, setShowExpandPopUp] = react_1.default.useState(false);
75
+ const expandMenuItems = [
76
+ {
77
+ id: 1,
78
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiPhoneStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
79
+ label: 'Default mode',
80
+ selected: isExpanded === widgetStore_1.WidgetExpandType.DEFAULT,
81
+ onClick: () => {
82
+ widgetStore_1.widgetStore.trigger.expandWidget({
83
+ expanded_size: widgetStore_1.WidgetExpandType.DEFAULT,
84
+ });
85
+ setExpandPopupOpen(false);
86
+ },
87
+ },
88
+ {
89
+ id: 2,
90
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiTabletStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
91
+ label: 'Expanded mode',
92
+ selected: isExpanded === widgetStore_1.WidgetExpandType.EXPANDED,
93
+ onClick: () => {
94
+ widgetStore_1.widgetStore.trigger.expandWidget({
95
+ expanded_size: widgetStore_1.WidgetExpandType.EXPANDED,
96
+ });
97
+ setExpandPopupOpen(false);
98
+ },
99
+ },
100
+ {
101
+ id: 3,
102
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiSpatialCurvedScreenStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
103
+ label: 'Full screen mode',
104
+ selected: isExpanded === widgetStore_1.WidgetExpandType.FULLSCREEN,
105
+ onClick: () => {
106
+ widgetStore_1.widgetStore.trigger.expandWidget({
107
+ expanded_size: widgetStore_1.WidgetExpandType.FULLSCREEN,
108
+ });
109
+ setExpandPopupOpen(false);
110
+ },
111
+ },
112
+ ];
113
+ const selectedExpandItem = expandMenuItems.find((item) => {
114
+ return item.selected ? item.icon : null;
115
+ });
116
+ (0, react_1.useEffect)(() => {
117
+ function handleClick(event) {
118
+ if (expandRef.current &&
119
+ !expandRef.current.contains(event.target)) {
120
+ setExpandPopupOpen(false);
121
+ }
122
+ }
123
+ if (expandPopupOpen) {
124
+ document.addEventListener('mousedown', handleClick);
125
+ }
126
+ return () => {
127
+ document.removeEventListener('mousedown', handleClick);
128
+ };
129
+ }, [expandPopupOpen]);
130
+ react_1.default.useEffect(() => {
131
+ if (expandPopupOpen) {
132
+ setShowExpandPopUp(true);
133
+ }
134
+ else if (showExpandPopUp) {
135
+ const timeout = setTimeout(() => setShowExpandPopUp(false), 140);
136
+ return () => clearTimeout(timeout);
137
+ }
138
+ }, [expandPopupOpen, showExpandPopUp]);
139
+ if (!Array.isArray(messageResponse) || messageResponse.length === 0) {
140
+ return ((0, jsx_runtime_1.jsx)("div", { className: "p-4 text-center text-gray-500", children: "No recent messages found." }));
141
+ }
142
+ const handleBackButtonClick = () => {
143
+ if (isExpanded) {
144
+ widgetStore_1.widgetStore.trigger.expandWidget({
145
+ expanded_size: widgetStore_1.WidgetExpandType.DEFAULT,
146
+ });
147
+ setTimeout(() => {
148
+ widgetStore_1.widgetStore.trigger.selectTab({
149
+ tab: widgetStore_1.TabType.RECENT_MESSAGE_LIST,
150
+ });
151
+ }, 300);
152
+ }
153
+ else {
154
+ widgetStore_1.widgetStore.trigger.selectTab({ tab: widgetStore_1.TabType.RECENT_MESSAGE_LIST });
155
+ }
156
+ };
157
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
+ const recentConversation1 = {
159
+ widget_id: '84b9d5a9-5322-4894-9e8d-c051a1f63cec',
160
+ conversation_id: '12242bc4-f2c6-472c-98f9-dc2984b6b1c2',
161
+ user_state: 'ALLOW_MESSAGE',
162
+ events: [
163
+ {
164
+ type: 'received',
165
+ time: '2025-06-24T07:27:48.676Z',
166
+ message: {
167
+ event_id: '885dc00e-01f6-4d87-a9b8-dc1117d29197',
168
+ output: [
169
+ {
170
+ response_type: 'greetings',
171
+ type: 'text',
172
+ value: {
173
+ type: 'text',
174
+ value: 'Hey there! Welcome to zomato support. How can I help you today? If you need to create a ticket, just let me know!',
175
+ },
176
+ },
177
+ ],
178
+ context: {
179
+ SYS_FirstName: 'Dhanush',
180
+ SYS_LastName: 'B',
181
+ SYS_Location: 'india',
182
+ SYS_Timezone: 'Asia/Kolkata',
183
+ SYS_UserEmail: 'dhanush.b@workativ.com',
184
+ },
185
+ system: {
186
+ conversationId: '12242bc4-f2c6-472c-98f9-dc2984b6b1c2',
187
+ platform: 'widget',
188
+ user: {
189
+ email: 'dhanush.b@workativ.com',
190
+ firstName: 'Dhanush',
191
+ lastName: 'B',
192
+ },
193
+ },
194
+ },
195
+ },
196
+ {
197
+ type: 'CONSENT_NEEDED',
198
+ consent: {
199
+ consent_display_data: {
200
+ type: 'text',
201
+ value: 'allow consent',
202
+ },
203
+ },
204
+ },
205
+ {
206
+ type: 'CONSENT_GIVEN',
207
+ submissionPayload: {
208
+ form_id: '68356e1e66c3922d39b8758a',
209
+ conversation_id: '5b105213-1ab7-4faa-b828-902965d0e5d1',
210
+ lead_data: {
211
+ name: 'new_form',
212
+ fields: [
213
+ {
214
+ field_id: 'SYS_browser',
215
+ value: 'Chrome',
216
+ },
217
+ {
218
+ field_id: 'SYS_browser_os',
219
+ value: 'Mac OS',
220
+ },
221
+ {
222
+ field_id: 'SYS_browser_language',
223
+ value: 'en-IN',
224
+ },
225
+ {
226
+ field_id: 'SYS_screen_resolution',
227
+ value: '1680 x 1050',
228
+ },
229
+ {
230
+ field_id: 'SYS_time_zone',
231
+ value: 'Asia/Calcutta',
232
+ },
233
+ {
234
+ field_id: 'SYS_device_type',
235
+ value: 'browser',
236
+ },
237
+ {
238
+ field_id: 'SYS_From_Page',
239
+ value: 'http://localhost:1234',
240
+ },
241
+ ],
242
+ ws: 'skitter',
243
+ user_consent: true,
244
+ },
245
+ type: 'browser',
246
+ },
247
+ },
248
+ {
249
+ type: 'FORM_INPUT_NEEDED',
250
+ form_data: {
251
+ _id: '68356e1f3e9aab349699a0ee',
252
+ name: 'new_form',
253
+ form_id: '68356e1e66c3922d39b8758a',
254
+ form_template: [
255
+ {
256
+ id: '678cd944f15097eed2f83da3',
257
+ name: 'Phone Number',
258
+ field_id: 'SYS_phone_number',
259
+ description: '',
260
+ dispaly_name: 'phonenumber',
261
+ placeholder: '',
262
+ is_mandatory: true,
263
+ _id: '684aed462ed03cfcece80ca3',
264
+ field_type: 'phone_number',
265
+ },
266
+ {
267
+ id: '678cd91cf15097eed2f83d9b',
268
+ name: 'First Name',
269
+ field_id: 'SYS_first_name',
270
+ description: '',
271
+ dispaly_name: 'first name',
272
+ placeholder: '',
273
+ is_mandatory: true,
274
+ _id: '684aed462ed03cfcece80ca4',
275
+ field_type: 'short_text',
276
+ },
277
+ {
278
+ id: '678cd944f15097eed2f83da2',
279
+ name: 'Country',
280
+ field_id: 'SYS_country',
281
+ description: '',
282
+ dispaly_name: '',
283
+ placeholder: '',
284
+ is_mandatory: true,
285
+ _id: '684aed462ed03cfcece80ca5',
286
+ field_type: 'country',
287
+ },
288
+ {
289
+ id: '678cd91cf15097eed2f83d9d',
290
+ name: 'Email',
291
+ field_id: 'SYS_email',
292
+ description: '',
293
+ dispaly_name: '',
294
+ placeholder: '',
295
+ is_mandatory: true,
296
+ _id: '684aed462ed03cfcece80ca6',
297
+ field_type: 'email',
298
+ },
299
+ {
300
+ id: '678cd91cf15097eed2f83d9c',
301
+ name: 'Last Name',
302
+ field_id: 'SYS_last_name',
303
+ description: '',
304
+ dispaly_name: '',
305
+ placeholder: '',
306
+ is_mandatory: true,
307
+ _id: '684aed462ed03cfcece80ca7',
308
+ field_type: 'short_text',
309
+ },
310
+ {
311
+ id: '6848460c2ed03cfcece7ab19',
312
+ name: 'Address',
313
+ field_id: 'iBv4WZbJrqe18DwrxkbvUF',
314
+ description: '',
315
+ dispaly_name: '',
316
+ placeholder: '',
317
+ is_mandatory: true,
318
+ _id: '684aed462ed03cfcece80ca8',
319
+ field_type: 'long_text',
320
+ },
321
+ ],
322
+ ws: 'skitter',
323
+ __v: 8,
324
+ },
325
+ },
326
+ {
327
+ type: 'FORM_SUBMITTED',
328
+ form_data: {
329
+ _id: '68356e1f3e9aab349699a0ee',
330
+ name: 'new_form',
331
+ form_id: '68356e1e66c3922d39b8758a',
332
+ form_template: [
333
+ {
334
+ id: '678cd944f15097eed2f83da3',
335
+ name: 'Phone Number',
336
+ field_id: 'SYS_phone_number',
337
+ description: '',
338
+ dispaly_name: 'phonenumber',
339
+ placeholder: '',
340
+ is_mandatory: true,
341
+ _id: '684aed462ed03cfcece80ca3',
342
+ field_type: 'phone_number',
343
+ },
344
+ {
345
+ id: '678cd91cf15097eed2f83d9b',
346
+ name: 'First Name',
347
+ field_id: 'SYS_first_name',
348
+ description: '',
349
+ dispaly_name: 'first name',
350
+ placeholder: '',
351
+ is_mandatory: true,
352
+ _id: '684aed462ed03cfcece80ca4',
353
+ field_type: 'short_text',
354
+ },
355
+ {
356
+ id: '678cd944f15097eed2f83da2',
357
+ name: 'Country',
358
+ field_id: 'SYS_country',
359
+ description: '',
360
+ dispaly_name: '',
361
+ placeholder: '',
362
+ is_mandatory: true,
363
+ _id: '684aed462ed03cfcece80ca5',
364
+ field_type: 'country',
365
+ },
366
+ {
367
+ id: '678cd91cf15097eed2f83d9d',
368
+ name: 'Email',
369
+ field_id: 'SYS_email',
370
+ description: '',
371
+ dispaly_name: '',
372
+ placeholder: '',
373
+ is_mandatory: true,
374
+ _id: '684aed462ed03cfcece80ca6',
375
+ field_type: 'email',
376
+ },
377
+ {
378
+ id: '678cd91cf15097eed2f83d9c',
379
+ name: 'Last Name',
380
+ field_id: 'SYS_last_name',
381
+ description: '',
382
+ dispaly_name: '',
383
+ placeholder: '',
384
+ is_mandatory: true,
385
+ _id: '684aed462ed03cfcece80ca7',
386
+ field_type: 'short_text',
387
+ },
388
+ {
389
+ id: '6848460c2ed03cfcece7ab19',
390
+ name: 'Address',
391
+ field_id: 'iBv4WZbJrqe18DwrxkbvUF',
392
+ description: '',
393
+ dispaly_name: '',
394
+ placeholder: '',
395
+ is_mandatory: true,
396
+ _id: '684aed462ed03cfcece80ca8',
397
+ field_type: 'long_text',
398
+ },
399
+ ],
400
+ ws: 'skitter',
401
+ __v: 8,
402
+ },
403
+ submissionPayload: {
404
+ form_id: '68356e1e66c3922d39b8758a',
405
+ conversation_id: '12242bc4-f2c6-472c-98f9-dc2984b6b1c2',
406
+ lead_data: {
407
+ name: 'new_form',
408
+ fields: [
409
+ {
410
+ field_id: 'SYS_phone_number',
411
+ value: '4567898769',
412
+ },
413
+ {
414
+ field_id: 'SYS_first_name',
415
+ value: 'Dhanush',
416
+ },
417
+ {
418
+ field_id: 'SYS_country',
419
+ value: 'Türkiye',
420
+ },
421
+ {
422
+ field_id: 'SYS_email',
423
+ value: 'dhanush.b@workativ.com',
424
+ },
425
+ {
426
+ field_id: 'SYS_last_name',
427
+ value: 'Hi',
428
+ },
429
+ {
430
+ field_id: 'iBv4WZbJrqe18DwrxkbvUF',
431
+ value: 'No.6\nDuraiswamy street visalatchi nagar ekkattuthangal',
432
+ },
433
+ ],
434
+ ws: 'skitter',
435
+ user_consent: true,
436
+ },
437
+ type: 'lead',
438
+ },
439
+ },
440
+ {
441
+ type: 'ALLOW_MESSAGE',
442
+ },
443
+ ],
444
+ };
445
+ const SubmittedEvent = recentConversation.events.find((e) => e.type === 'FORM_SUBMITTED');
446
+ // const submittedFields =
447
+ // recentConversation.events.find((e) => e.type === 'FORM_SUBMITTED')
448
+ // ?.submissionPayload?.lead_data?.fields ?? []
449
+ // console.log(
450
+ // 'found form submitted value',
451
+ // recentConversation.events.find((e) => e.type === 'FORM_SUBMITTED')
452
+ // ?.submissionPayload.lead_data.fields
453
+ // )
454
+ // const submittedValueMap = submittedFields.reduce(
455
+ // (acc, field) => {
456
+ // acc[field.field_id] = field.value
457
+ // return acc
458
+ // },
459
+ // {} as Record<string, string>
460
+ // )
461
+ // console.log(formTemplate, 'formTemplate')
462
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("header", { className: "flex items-center px-0 py-[15px] border-b border-zinc-300 w-full justify-between h-[60px] bg-white rounded-t-[22px] cursor-pointer", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 px-5 w-full", children: [(0, jsx_runtime_1.jsx)("button", { className: "inline-flex items-center justify-center gap-2.5 p-0 cursor-pointer hover:bg-slate-100 rounded-xl overflow-hidden", onClick: handleBackButtonClick, children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiChevronLeftStroke, { className: "w-6 h-6" }) }), (0, jsx_runtime_1.jsx)("img", { className: "w-[30px] h-[30px]", src: widget?.data?.logo_url, alt: "Bot logo" }), (0, jsx_runtime_1.jsx)("span", { className: "flex flex-col items-start grow", children: (0, jsx_runtime_1.jsx)("span", { className: "flex flex-col items-start gap-[18px] flex-[0_0_auto]", children: (0, jsx_runtime_1.jsx)("h1", { className: "w-fit mt-[-1.00px] font-text-md-medium font-[number:var(--text-md-medium-font-weight)] text-[#020618] text-[length:var(--text-md-medium-font-size)] tracking-[var(--text-md-medium-letter-spacing)] leading-[var(--text-md-medium-line-height)] whitespace-nowrap [font-style:var(--text-md-medium-font-style)]", children: widget?.data?.name }) }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 px-5", children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative", ref: expandRef, children: [(0, jsx_runtime_1.jsx)("button", { className: "inline-flex items-center gap-2.5 p-1 cursor-pointer hover:bg-slate-100 rounded-lg overflow-hidden", onClick: () => setExpandPopupOpen(!expandPopupOpen), children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center gap-2.5", children: selectedExpandItem
463
+ ? selectedExpandItem.icon
464
+ : null }) }), showExpandPopUp && ((0, jsx_runtime_1.jsxs)("nav", { className: `flex flex-col w-[148px] h-max absolute items-start gap-1 p-1 right-0 bg-white rounded-lg overflow-hidden border border-solid border-slate-200 z-50`, style: {
465
+ animation: expandPopupOpen
466
+ ? 'popin 0.18s cubic-bezier(0.4,0,0.2,1)'
467
+ : 'popout 0.14s cubic-bezier(0.4,0,0.2,1)',
468
+ }, children: [(0, jsx_runtime_1.jsx)("style", { children: `
469
+ @keyframes popin {
470
+ 0% {
471
+ opacity: 0;
472
+ transform: scale(0.95) translateY(-8px);
473
+ }
474
+ 100% {
475
+ opacity: 1;
476
+ transform: scale(1) translateY(0);
477
+ }
478
+ }
479
+ @keyframes popout {
480
+ 0% {
481
+ opacity: 1;
482
+ transform: scale(1) translateY(0);
483
+ }
484
+ 100% {
485
+ opacity: 0;
486
+ transform: scale(0.95) translateY(-8px);
487
+ }
488
+ }
489
+ ` }), expandMenuItems.map((item) => ((0, jsx_runtime_1.jsxs)("button", { className: `flex items-center gap-1.5 pl-2 pr-3 py-1.5 relative self-stretch w-full cursor-pointer
490
+ hover:bg-slate-100 rounded-md overflow-hidden`, style: {
491
+ backgroundColor: item.selected
492
+ ? '#f0f0f0'
493
+ : '',
494
+ }, onClick: item.onClick, children: [(0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center gap-2.5 flex-[0_0_auto]", children: item.icon }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start justify-center gap-2 flex-1 self-stretch grow", children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex flex-col items-start gap-1 flex-[0_0_auto]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-1 flex-[0_0_auto]", children: (0, jsx_runtime_1.jsx)("div", { className: "w-fit whitespace-nowrap text-xs font-medium text-[#020618]", children: item.label }) }) }) })] }, item.id)))] }))] }), (0, jsx_runtime_1.jsx)("button", { className: "inline-flex items-center p-1 hover:bg-slate-50 rounded-lg cursor-pointer", onClick: toggleWidget, children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiMultipleCrossCancelDefaultStroke, { className: "w-[18px] h-[18px]" }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col h-[calc(100%-80px)] justify-between w-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex flex-col gap-4 h-full overflow-y-scroll w-full -mt-[12px] mb-[6px]", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col gap-5 w-full", children: [SubmittedEvent != undefined ? ((0, jsx_runtime_1.jsx)(RenderForm, { event: SubmittedEvent })) : null, messageResponse.map((message, index) => ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [console.log(message.type, 'message type'), message.type === 'received' ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [console.log('message from new recentchat', message), (0, jsx_runtime_1.jsx)(ReceivedMessage_1.ReceivedMessage, { message: message.message, time: message.time, sendFeedback: function () {
495
+ throw new Error('Function not implemented.');
496
+ }, sendMessage: function () {
497
+ throw new Error('Function not implemented.');
498
+ } })] })) : ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-end px-5 animate-slide-in-right", children: (0, jsx_runtime_1.jsx)("div", { className: "w-[300px] flex flex-col items-end gap-1", children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-1 text-sm px-3.5 py-2.5 rounded-lg", style: {
499
+ backgroundColor: widget?.data
500
+ ?.secondary_color,
501
+ color: widget?.data
502
+ ?.user_message_text_color,
503
+ }, children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.message
504
+ .input ?? '' }) }) }) }))] }) }, index)))] }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-2.5 bg-white", children: (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-center justify-center gap-8 w-full overflow-hidden border border-zinc-100", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2.5 px-4 py-2 w-full bg-white", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center gap-1.5 flex-1", children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex flex-col items-start justify-center", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-center w-full gap-1.5 pb-0.5", children: (0, jsx_runtime_1.jsx)("span", { className: "font-text-xs-regular text-[#1d293d] text-xs tracking-[0px] leading-[18px] whitespace-nowrap", children: "Your conversation has ended" }) }) }) }) }) }) })] })] }));
505
+ };
506
+ exports.NewRecentMessagePage = NewRecentMessagePage;
507
+ const RenderForm = ({ event }) => {
508
+ const submittedFields = event.submissionPayload?.lead_data?.fields ?? [];
509
+ // console.log(
510
+ // 'found form submitted value',
511
+ // recentConversation.events.find((e) => e.type === 'FORM_SUBMITTED')
512
+ // ?.submissionPayload.lead_data.fields
513
+ // )
514
+ const submittedValueMap = submittedFields.reduce((acc, field) => {
515
+ acc[field.field_id] = field.value;
516
+ return acc;
517
+ }, {});
518
+ const formTemplate = event?.form_data?.form_template;
519
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
520
+ const [isSubmittedFormOpen, setIsSubmittedFormOpen] = (0, react_1.useState)(false);
521
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden px-5", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex items-center gap-2 ", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-[5px]", children: (0, jsx_runtime_1.jsx)("div", { className: "flex w-[24px] h-[24px] items-center justify-center rounded-full", children: (0, jsx_runtime_1.jsx)("img", { src: widget?.data?.logo_url, className: "w-6 h-6 text-white" }) }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex-col flex gap-2 items-baseline pt-0.5 w-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "font-inter text-sm font-medium text-[#020618]", children: widget?.data?.name }), (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1.00px] text-sm text-[#020618] w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: `${isSubmittedFormOpen ? 'py-2.5 px-3.5' : 'py-2.5 px-3.5'} flex w-full flex-col items-start gap-4 rounded-lg border border-zinc-200`, children: [(0, jsx_runtime_1.jsxs)("div", { className: `${isSubmittedFormOpen ? 'py-0.5 pr-1' : 'py-0.5 pr-1'} flex items-center gap-2 rounded-sm w-full justify-between`, children: [(0, jsx_runtime_1.jsxs)("span", { className: "flex gap-1 items-center text-slate-950 text-sm font-regular leading-5", children: ["Form submitted", ' ', (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiCheckTickCircleSolid, { className: "h-[18px] w-[18px] text-green-500" })] }), (0, jsx_runtime_1.jsx)("span", { onClick: () => setIsSubmittedFormOpen(!isSubmittedFormOpen), className: "cursor-pointer text-slate-500 hover:text-slate-700 transition-colors hover:bg-slate-100 rounded-full", children: !isSubmittedFormOpen ? ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiChevronDownStroke, {})) : ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiChevronUpStroke, { className: "" })) })] }), isSubmittedFormOpen && ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-4", children: formTemplate &&
522
+ formTemplate.map((input, index) => ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-1.5", children: [(0, jsx_runtime_1.jsx)("span", { className: "text-slate-700 text-sm font-medium leading-5", children: input.dispaly_name
523
+ ? input.dispaly_name
524
+ : input.name }), (0, jsx_runtime_1.jsx)("span", { className: "text-slate-950 text-sm font-regular leading-5", children: submittedValueMap?.[input.field_id] })] }, index))) }))] }) })] }) })] }));
525
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NewRecentMessageTab = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const useCurrentConversationExists_1 = require("./hooks/useCurrentConversationExists");
7
+ const widgetConfigStore2_1 = require("./widgetConfigStore2");
8
+ const widgetStore_1 = require("./widgetStore");
9
+ const NewRecentMessageTab = () => {
10
+ const { hasRecentConversation, recentConversation } = (0, useCurrentConversationExists_1.useCurrentConversationExist)();
11
+ const [isHovered, setIsHovered] = (0, react_1.useState)(false);
12
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
13
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: hasRecentConversation && ((0, jsx_runtime_1.jsx)("div", { className: "w-full flex items-center gap-2.5 pl-5 pr-4 py-3 rounded-xl border bg-white cursor-pointer", onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), onClick: () => widgetStore_1.widgetStore.trigger.selectTab({
14
+ tab: widgetStore_1.TabType.CHAT,
15
+ }), style: {
16
+ borderColor: isHovered
17
+ ? widget?.data?.brand_color
18
+ : '#cad5e2',
19
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: "flex-col items-start gap-1 flex-1 grow flex w-[91%]", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex-col items-start gap-1 self-stretch w-full flex", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex-col items-start gap-[18px] self-stretch w-full flex", children: (0, jsx_runtime_1.jsx)("h3", { className: "w-fit mt-[-1.00px] text-sm font-semibold text-[#020618]", children: "Recent messagess" }) }), (0, jsx_runtime_1.jsx)("div", { title: "Hello! Thanks for contacting us! all of\n our team", className: "flex-col items-start gap-[18px] self-stretch w-full flex", children: (0, jsx_runtime_1.jsx)("p", { className: "self-stretch mt-[-1.00px] text-sm text-[#020618] leading-5 whitespace-nowrap overflow-hidden text-ellipsis w-full", children: recentConversation &&
20
+ recentConversation.events[0].message
21
+ ?.output[0].value.value }) })] }) }) })) }));
22
+ };
23
+ exports.NewRecentMessageTab = NewRecentMessageTab;