pager-widget 1.0.11-alpha.9 → 1.0.13

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 (79) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.html +40 -0
  3. package/dist/index.js +8 -8
  4. package/dist/react-parcel.9f367d21.css +2970 -0
  5. package/dist/react-parcel.9f367d21.css.map +1 -0
  6. package/dist/react-parcel.js +231527 -0
  7. package/dist/react-parcel.js.map +1 -0
  8. package/dist/server.html +33 -39
  9. package/out/AgentFeedbackButtonWrapper.js +15 -0
  10. package/out/App.js +28 -0
  11. package/out/BotMain.js +91 -0
  12. package/out/ButtonsWrapper.js +29 -0
  13. package/out/ChatPage.js +9 -0
  14. package/out/ChatPageContent.js +131 -0
  15. package/out/ChatPageHeader.js +267 -0
  16. package/out/ChatPageInput.js +29 -0
  17. package/out/ChatWidget.js +17 -0
  18. package/out/Consent.js +66 -0
  19. package/out/CountryDropdown.js +31 -0
  20. package/out/Form.js +238 -0
  21. package/out/HomePage.js +11 -0
  22. package/out/HomePageContent.js +32 -0
  23. package/out/HomePageFooter.js +87 -0
  24. package/out/HomePageHeader.js +66 -0
  25. package/out/InputField.js +80 -0
  26. package/out/Markdown.js +126 -0
  27. package/out/Message.js +197 -0
  28. package/out/MessagesT.js +2 -0
  29. package/out/NewRecentMessagePage.js +525 -0
  30. package/out/NewRecentMessageTab.js +23 -0
  31. package/out/ReceivedMessage.js +211 -0
  32. package/out/RecentMessageDetail.js +178 -0
  33. package/out/RecentMessageList.js +112 -0
  34. package/out/RecentMessageListCard.js +20 -0
  35. package/out/RecentMessageListHeader.js +156 -0
  36. package/out/RecentMessagePage.js +183 -0
  37. package/out/RecentMessageTab.js +35 -0
  38. package/out/WidgetMessage.js +14 -0
  39. package/out/WidgetToggleButton.js +191 -0
  40. package/out/WidgetType.js +2 -0
  41. package/out/assets/icons/pikaicons-react.js +17475 -0
  42. package/out/components/ConsentForm.js +7 -0
  43. package/out/components/CustomTooltip.js +34 -0
  44. package/out/hooks/useChatHistoryExists.js +32 -0
  45. package/out/hooks/useChatHistoryListExist.js +81 -0
  46. package/out/hooks/useChatScroll.js +14 -0
  47. package/out/hooks/useCurrentConversationExists.js +88 -0
  48. package/out/hooks/useInitialMessage.js +33 -0
  49. package/out/hooks/useMessage.js +230 -0
  50. package/out/hooks/useMessageReceiver.js +183 -0
  51. package/out/hooks/usePopupAnimation.js +20 -0
  52. package/out/hooks/useSocket.js +19 -0
  53. package/out/hooks/useSocketContext.js +81 -0
  54. package/out/hooks/useWidgetDimension.js +41 -0
  55. package/out/hooks/useWidgetToggle.js +22 -0
  56. package/out/index.js +31 -0
  57. package/out/markdown/CodeCopy.js +22 -0
  58. package/out/markdown/CodeHighlight.js +58 -0
  59. package/out/markdown/PagerMarkdown.js +36 -0
  60. package/out/markdown/pager_md.js +152 -0
  61. package/out/onscreenNotificationPopup.js +23 -0
  62. package/out/socket.js +11 -0
  63. package/out/utils/checkConversationExit.js +24 -0
  64. package/out/utils/convertTime.js +43 -0
  65. package/out/utils/sendInitialMessage.js +82 -0
  66. package/out/widget.js +21 -0
  67. package/out/widgetConfigStore.js +205 -0
  68. package/out/widgetConfigStore2.js +569 -0
  69. package/out/widgetControlstore.js +23 -0
  70. package/out/widgetStateHandler.js +106 -0
  71. package/out/widgetStore.js +171 -0
  72. package/out/widgetUserStore.js +47 -0
  73. package/package.json +3 -3
  74. package/server.html +33 -39
  75. package/.husky/pre-commit +0 -4
  76. package/docs/issues/001-use-widget-resize-hook.md +0 -51
  77. package/docs/issues/002-embed-snippet-container-resize.md +0 -81
  78. package/docs/prd/0001-iframe-resize-scroll-through.md +0 -333
  79. package/test-iframe-resize.html +0 -74
@@ -0,0 +1,267 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.ChatPageHeader = void 0;
37
+ const jsx_runtime_1 = require("react/jsx-runtime");
38
+ const react_1 = __importStar(require("react"));
39
+ const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
40
+ const widgetConfigStore2_1 = require("./widgetConfigStore2");
41
+ const BotMain_1 = require("./BotMain");
42
+ const widgetStore_1 = require("./widgetStore");
43
+ const ChatPageHeader = ({ toggleWidget, isExpanded, restart, exit, }) => {
44
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
45
+ const [isMenuOpen, setIsMenuOpen] = react_1.default.useState(false);
46
+ const [showMenu, setShowMenu] = react_1.default.useState(false);
47
+ const ref = react_1.default.useRef(null);
48
+ const expandRef = react_1.default.useRef(null);
49
+ const [expandPopupOpen, setExpandPopupOpen] = react_1.default.useState(false);
50
+ const [showExpandPopUp, setShowExpandPopUp] = react_1.default.useState(false);
51
+ const handleRestartChat = () => {
52
+ // Step 1: Read current object from 'CONVERSATION'
53
+ const raw = localStorage.getItem(`CONVERSATION::${widget.data.id}`);
54
+ if (!raw) {
55
+ console.warn('No data found in CONVERSATION key');
56
+ return;
57
+ }
58
+ try {
59
+ const currentData = JSON.parse(raw);
60
+ // Step 2: Get existing array from 'CONVERASATION_LIST'
61
+ const listRaw = localStorage.getItem(`CONVERSATION_LIST::${widget.data.id}`);
62
+ const currentList = listRaw ? JSON.parse(listRaw) : [];
63
+ // Step 3: Append the current object
64
+ currentList.push(currentData);
65
+ // Step 4: Save back to CONVERSATION_LIST'
66
+ localStorage.setItem(`CONVERSATION_LIST::${widget.data.id}`, JSON.stringify(currentList));
67
+ localStorage.removeItem(`CONVERSATION::${widget.data.id}`);
68
+ localStorage.removeItem('CURRENT_CONVERSATION');
69
+ // Step 5: Perform other exit actions
70
+ restart();
71
+ // widgetFetchStore2.trigger.exitConversation()
72
+ // Optional: Also update widget state
73
+ // widgetStore.send({ type: 'handleExitChatState', value: true })
74
+ }
75
+ catch (error) {
76
+ console.error('Failed to parse localStorage data:', error);
77
+ }
78
+ };
79
+ const handleExitChat = () => {
80
+ console.log('exit triggering');
81
+ exit();
82
+ };
83
+ const menuItems = [
84
+ {
85
+ id: 1,
86
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiRefreshSolid, { className: "w-[14px] h-[14px] text-slate-600" })),
87
+ label: 'Restart chat',
88
+ selected: true,
89
+ onClick: () => {
90
+ handleRestartChat();
91
+ setIsMenuOpen(false);
92
+ },
93
+ },
94
+ {
95
+ id: 2,
96
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiStopBigStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
97
+ label: 'Exit chat',
98
+ selected: false,
99
+ onClick: () => {
100
+ handleExitChat();
101
+ setIsMenuOpen(false);
102
+ // handleBackButtonClick()
103
+ },
104
+ },
105
+ ];
106
+ const expandMenuItems = [
107
+ {
108
+ id: 1,
109
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiPhoneStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
110
+ label: 'Default mode',
111
+ selected: isExpanded === widgetStore_1.WidgetExpandType.DEFAULT,
112
+ onClick: () => {
113
+ widgetStore_1.widgetStore.trigger.expandWidget({
114
+ expanded_size: widgetStore_1.WidgetExpandType.DEFAULT,
115
+ });
116
+ setExpandPopupOpen(false);
117
+ },
118
+ },
119
+ {
120
+ id: 2,
121
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiTabletStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
122
+ label: 'Expanded mode',
123
+ selected: isExpanded === widgetStore_1.WidgetExpandType.EXPANDED,
124
+ onClick: () => {
125
+ widgetStore_1.widgetStore.trigger.expandWidget({
126
+ expanded_size: widgetStore_1.WidgetExpandType.EXPANDED,
127
+ });
128
+ setExpandPopupOpen(false);
129
+ },
130
+ },
131
+ {
132
+ id: 3,
133
+ icon: ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiSpatialCurvedScreenStroke, { className: "w-[16px] h-[16px] text-slate-600" })),
134
+ label: 'Full screen mode',
135
+ selected: isExpanded === widgetStore_1.WidgetExpandType.FULLSCREEN,
136
+ onClick: () => {
137
+ widgetStore_1.widgetStore.trigger.expandWidget({
138
+ expanded_size: widgetStore_1.WidgetExpandType.FULLSCREEN,
139
+ });
140
+ setExpandPopupOpen(false);
141
+ },
142
+ },
143
+ ];
144
+ const selectedExpandItem = expandMenuItems.find((item) => {
145
+ return item.selected ? item.icon : null;
146
+ });
147
+ (0, react_1.useEffect)(() => {
148
+ function handleClick(event) {
149
+ if (ref.current && !ref.current.contains(event.target)) {
150
+ setIsMenuOpen(false);
151
+ }
152
+ }
153
+ if (isMenuOpen) {
154
+ document.addEventListener('mousedown', handleClick);
155
+ }
156
+ return () => {
157
+ document.removeEventListener('mousedown', handleClick);
158
+ };
159
+ }, [isMenuOpen]);
160
+ (0, react_1.useEffect)(() => {
161
+ function handleClick(event) {
162
+ if (expandRef.current &&
163
+ !expandRef.current.contains(event.target)) {
164
+ setExpandPopupOpen(false);
165
+ }
166
+ }
167
+ if (expandPopupOpen) {
168
+ document.addEventListener('mousedown', handleClick);
169
+ }
170
+ return () => {
171
+ document.removeEventListener('mousedown', handleClick);
172
+ };
173
+ }, [expandPopupOpen]);
174
+ react_1.default.useEffect(() => {
175
+ if (isMenuOpen) {
176
+ setShowMenu(true);
177
+ }
178
+ else if (showMenu) {
179
+ const timeout = setTimeout(() => setShowMenu(false), 140);
180
+ return () => clearTimeout(timeout);
181
+ }
182
+ }, [isMenuOpen, showMenu]);
183
+ react_1.default.useEffect(() => {
184
+ if (expandPopupOpen) {
185
+ setShowExpandPopUp(true);
186
+ }
187
+ else if (showExpandPopUp) {
188
+ const timeout = setTimeout(() => setShowExpandPopUp(false), 140);
189
+ return () => clearTimeout(timeout);
190
+ }
191
+ }, [expandPopupOpen, showExpandPopUp]);
192
+ const handleBackButtonClick = () => {
193
+ if (isExpanded !== widgetStore_1.WidgetExpandType.DEFAULT) {
194
+ widgetStore_1.widgetStore.trigger.expandWidget({
195
+ expanded_size: widgetStore_1.WidgetExpandType.DEFAULT,
196
+ });
197
+ setTimeout(() => {
198
+ widgetStore_1.widgetStore.trigger.selectTab({ tab: BotMain_1.TabType.HOME });
199
+ }, 300);
200
+ widgetStore_1.widgetStore.trigger.handleExitChatState({ value: false });
201
+ }
202
+ else {
203
+ widgetStore_1.widgetStore.trigger.selectTab({ tab: BotMain_1.TabType.HOME });
204
+ widgetStore_1.widgetStore.send({ type: 'handleExitChatState', value: false });
205
+ }
206
+ };
207
+ return ((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]", "data-model-id": "10445:55564", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2 px-5 py-0 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 cursor-pointer" }) }), (0, jsx_runtime_1.jsx)("img", { className: "w-auto h-[30px]", src: widget?.data?.logo_url }), (0, jsx_runtime_1.jsx)("span", { className: "flex flex-col items-start flex-1 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 py-0 w-max justify-end", children: [(0, jsx_runtime_1.jsxs)("div", { className: "relative", ref: ref, 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: () => setIsMenuOpen(!isMenuOpen), children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center gap-2.5", children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiThreeDotsMenuVerticalStroke, { className: "w-[16px] h-[16px]" }) }) }), showMenu && ((0, jsx_runtime_1.jsxs)("nav", { className: `flex flex-col w-[126px] 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: {
208
+ animation: isMenuOpen
209
+ ? 'popin 0.18s cubic-bezier(0.4,0,0.2,1)'
210
+ : 'popout 0.14s cubic-bezier(0.4,0,0.2,1)',
211
+ }, children: [(0, jsx_runtime_1.jsx)("style", { children: `
212
+ @keyframes popin {
213
+ 0% {
214
+ opacity: 0;
215
+ transform: scale(0.95) translateY(-8px);
216
+ }
217
+ 100% {
218
+ opacity: 1;
219
+ transform: scale(1) translateY(0);
220
+ }
221
+ }
222
+ @keyframes popout {
223
+ 0% {
224
+ opacity: 1;
225
+ transform: scale(1) translateY(0);
226
+ }
227
+ 100% {
228
+ opacity: 0;
229
+ transform: scale(0.95) translateY(-8px);
230
+ }
231
+ }
232
+ ` }), menuItems.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
233
+ hover:bg-slate-100 rounded-md overflow-hidden`, 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.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
234
+ ? selectedExpandItem.icon
235
+ : 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: {
236
+ animation: expandPopupOpen
237
+ ? 'popin 0.18s cubic-bezier(0.4,0,0.2,1)'
238
+ : 'popout 0.14s cubic-bezier(0.4,0,0.2,1)',
239
+ }, children: [(0, jsx_runtime_1.jsx)("style", { children: `
240
+ @keyframes popin {
241
+ 0% {
242
+ opacity: 0;
243
+ transform: scale(0.95) translateY(-8px);
244
+ }
245
+ 100% {
246
+ opacity: 1;
247
+ transform: scale(1) translateY(0);
248
+ }
249
+ }
250
+ @keyframes popout {
251
+ 0% {
252
+ opacity: 1;
253
+ transform: scale(1) translateY(0);
254
+ }
255
+ 100% {
256
+ opacity: 0;
257
+ transform: scale(0.95) translateY(-8px);
258
+ }
259
+ }
260
+ ` }), 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
261
+ hover:bg-slate-100 rounded-md overflow-hidden`, style: {
262
+ backgroundColor: item.selected
263
+ ? '#f0f0f0'
264
+ : '',
265
+ }, 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 gap-2.5 p-1 cursor-pointer hover:bg-slate-100 rounded-lg overflow-hidden", onClick: toggleWidget, children: (0, jsx_runtime_1.jsx)("div", { className: "inline-flex items-center gap-2.5", children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiMultipleCrossCancelDefaultStroke, { className: "w-[18px] h-[18px]" }) }) })] })] }));
266
+ };
267
+ exports.ChatPageHeader = ChatPageHeader;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ChatPageInput = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const widgetConfigStore2_1 = require("./widgetConfigStore2");
7
+ const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
8
+ const ChatPageInput = ({ sendMessage }) => {
9
+ const [typedMessage, setTypedMessage] = (0, react_1.useState)('');
10
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
11
+ const [isSendHover, setIsSendHover] = (0, react_1.useState)(false);
12
+ const send = () => {
13
+ if (typedMessage.trim()) {
14
+ sendMessage(typedMessage);
15
+ }
16
+ setTypedMessage('');
17
+ };
18
+ return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: widget.status === 'ALLOW_MESSAGE' && ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start p-5 gap-2.5", children: (0, jsx_runtime_1.jsx)("div", { className: "w-full border border-zinc-300 rounded-lg overflow-hidden bg-white", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center gap-2.5 px-4 py-2.5", children: [(0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: "Enter message", className: "flex-1 text-sm text-[#1d293d] placeholder-[#62748e] outline-none", value: typedMessage, onChange: (e) => setTypedMessage(e.target.value), onKeyDown: (e) => {
19
+ if (e.key === 'Enter') {
20
+ e.preventDefault();
21
+ send();
22
+ }
23
+ } }), (0, jsx_runtime_1.jsx)("button", { className: "p-1.5 rounded-full transition-colors cursor-pointer flex items-center justify-center", onClick: () => send(), onMouseEnter: () => setIsSendHover(true), onMouseLeave: () => setIsSendHover(false), style: {
24
+ color: isSendHover
25
+ ? widget.data?.brand_color || '#4B2FFF'
26
+ : '#62748e',
27
+ }, children: isSendHover ? ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiSendPlaneSlantSolid, { className: "w-5 h-5" })) : ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiSendPlaneSlantStroke, { className: "w-5 h-5" })) })] }) }) })) }));
28
+ };
29
+ exports.ChatPageInput = ChatPageInput;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.ChatWidget = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const widgetConfigStore2_1 = require("./widgetConfigStore2");
9
+ const BotMain_1 = __importDefault(require("./BotMain"));
10
+ const useSocketContext_1 = require("./hooks/useSocketContext");
11
+ const ChatWidget = ({ widgetToggleState, toggleWidget, widgetConfig, }) => {
12
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
13
+ console.log('DEBUG:: widget', widget);
14
+ const isWidgetOpen = widgetToggleState === 'OPEN' && widget.status !== 'INVALID_STATE';
15
+ return ((0, jsx_runtime_1.jsx)(useSocketContext_1.SocketProvider, { endpoint: widgetConfig.endpoint, children: isWidgetOpen && ((0, jsx_runtime_1.jsx)(BotMain_1.default, { toggleWidget: toggleWidget, widgetToggleState: widgetToggleState, widgetConfig: widgetConfig })) }));
16
+ };
17
+ exports.ChatWidget = ChatWidget;
package/out/Consent.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Consent = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const widgetConfigStore2_1 = require("./widgetConfigStore2");
9
+ const react_device_detect_1 = require("react-device-detect");
10
+ const uuid_1 = require("uuid");
11
+ const pager_md_1 = __importDefault(require("./markdown/pager_md"));
12
+ const widgetStore_1 = require("./widgetStore");
13
+ const Consent = () => {
14
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
15
+ // const current_conversation_id = useGetCurrentConversationId()
16
+ if (widget.status === 'CONSENT_NEEDED') {
17
+ let systemDetails;
18
+ let submissionPayload;
19
+ if (widget.status === 'CONSENT_NEEDED') {
20
+ const language = navigator.language;
21
+ const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
22
+ systemDetails = [
23
+ { field_id: 'SYS_browser', value: react_device_detect_1.browserName },
24
+ { field_id: 'SYS_browser_os', value: react_device_detect_1.osName },
25
+ { field_id: 'SYS_browser_language', value: language },
26
+ {
27
+ field_id: 'SYS_screen_resolution',
28
+ value: `${window.screen.width} x ${window.screen.height}`,
29
+ },
30
+ { field_id: 'SYS_time_zone', value: timeZone },
31
+ { field_id: 'SYS_device_type', value: react_device_detect_1.deviceType },
32
+ { field_id: 'SYS_From_Page', value: window.location.origin },
33
+ ];
34
+ submissionPayload = {
35
+ form_id: widget?.form_data?.form_id ?? '',
36
+ conversation_id: (0, uuid_1.v4)(),
37
+ lead_data: {
38
+ name: widget?.form_data?.name,
39
+ fields: systemDetails,
40
+ ws: widget?.data?.workspace,
41
+ user_consent: widget?.data.user_consent,
42
+ },
43
+ type: 'browser',
44
+ };
45
+ }
46
+ const ConsentGiven = () => {
47
+ widgetConfigStore2_1.widgetFetchStore2.trigger.processConsent({
48
+ consentState: 'GIVEN',
49
+ submissionPayload,
50
+ });
51
+ };
52
+ const ConsentDenied = () => {
53
+ // widgetFetchStore2.trigger.processConsent({
54
+ // consentState: 'DENIED',
55
+ // submissionPayload,
56
+ // })
57
+ widgetStore_1.widgetStore.trigger.selectTab({ tab: widgetStore_1.TabType.HOME });
58
+ };
59
+ console.log('hereconsent', widget.consent);
60
+ return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full px-5 animate-slide-in-left", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full flex-col gap-2.5", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex gap-2 items-start w-full rounded-lg overflow-hidden", 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.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%]", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-full", children: [(0, jsx_runtime_1.jsx)("div", { className: "flex gap-2 items-baseline pt-0.5", 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.jsx)(pager_md_1.default, { mdText: widget?.consent
61
+ .consent_display_data // TODO: fix this any
62
+ }) })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-wrap items-start gap-2 relative self-stretch pt-1", children: [(0, jsx_runtime_1.jsx)("button", { onClick: ConsentGiven, className: "flex cursor-pointer !h-7 w-max border border-slate-300 leading-5 px-3.5 py-1.5 font-medium text-slate-700 items-center text-sm justify-center bg-white rounded-lg hover:border-[#4b2fff]", children: "Yes, I agree" }), (0, jsx_runtime_1.jsx)("button", { onClick: ConsentDenied, className: "flex cursor-pointer !h-7 w-max border border-slate-300 leading-5 px-3.5 py-1.5 font-medium text-slate-700 items-center text-sm justify-center bg-white rounded-lg hover:border-[#4b2fff]", children: "No, I do not agree" })] })] })] }) }) }));
63
+ }
64
+ return null;
65
+ };
66
+ exports.Consent = Consent;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CountryDropdown = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const CountryDropdown = ({ countries, value, onChange, disabled, error, placeholder = 'Select a country', label = 'Country', }) => {
7
+ const [isOpen, setIsOpen] = (0, react_1.useState)(false);
8
+ const [search, setSearch] = (0, react_1.useState)('');
9
+ const dropdownRef = (0, react_1.useRef)(null);
10
+ const filteredCountries = countries.filter((c) => c.name.toLowerCase().includes(search.toLowerCase()));
11
+ (0, react_1.useEffect)(() => {
12
+ const handleClickOutside = (event) => {
13
+ if (dropdownRef.current &&
14
+ !dropdownRef.current.contains(event.target)) {
15
+ setIsOpen(false);
16
+ }
17
+ };
18
+ document.addEventListener('mousedown', handleClickOutside);
19
+ return () => document.removeEventListener('mousedown', handleClickOutside);
20
+ }, []);
21
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "w-full", ref: dropdownRef, children: [(0, jsx_runtime_1.jsx)("label", { className: "block text-sm font-medium text-gray-700 mb-1", children: label }), (0, jsx_runtime_1.jsxs)("div", { onClick: () => {
22
+ if (!disabled)
23
+ setIsOpen((prev) => !prev);
24
+ }, className: `w-full flex justify-between items-center px-4 py-2 h-9 text-sm rounded-lg border ${disabled ? 'text-slate-400 border-zinc-200 bg-zinc-50' : 'bg-white'} ${error
25
+ ? 'border-red-500 focus:ring-red-500'
26
+ : 'border-gray-300 focus:ring-blue-500'} focus:outline-none focus:ring-2 focus:border-transparent`, children: [(0, jsx_runtime_1.jsx)("span", { className: "truncate", children: value || placeholder }), (0, jsx_runtime_1.jsx)("svg", { className: "w-4 h-4 ml-2", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: (0, jsx_runtime_1.jsx)("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M19 9l-7 7-7-7" }) })] }), isOpen && ((0, jsx_runtime_1.jsxs)("div", { className: "z-50 mt-1 w-[100%] bg-white border border-gray-300 rounded-md shadow-lg", onMouseDown: (e) => e.stopPropagation(), children: [(0, jsx_runtime_1.jsx)("div", { className: "p-2 border-b border-gray-200 bg-white sticky top-0 z-10 rounded-tl-md rounded-tr-md", children: (0, jsx_runtime_1.jsx)("input", { type: "text", placeholder: "Search", value: search, onChange: (e) => setSearch(e.target.value), onMouseDown: (e) => e.stopPropagation(), className: "w-full px-2 py-1 text-sm border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "max-h-48 overflow-y-auto", children: [filteredCountries.map((c) => ((0, jsx_runtime_1.jsx)("div", { onClick: () => {
27
+ onChange(c.name);
28
+ setIsOpen(false);
29
+ }, className: "px-4 py-2 hover:bg-gray-100 cursor-pointer text-sm", children: c.name }, c.code))), filteredCountries.length === 0 && ((0, jsx_runtime_1.jsx)("li", { className: "px-4 py-2 text-sm text-gray-500", children: "No results found" }))] })] })), error && (0, jsx_runtime_1.jsx)("p", { className: "text-red-500 text-xs mt-1", children: error })] }));
30
+ };
31
+ exports.CountryDropdown = CountryDropdown;