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,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InputField = void 0;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const country_codes_flags_phone_codes_1 = require("country-codes-flags-phone-codes");
6
+ const CountryDropdown_1 = require("./CountryDropdown");
7
+ const InputField = ({ input, handleChange, value, error, disabled, }) => {
8
+ // const [selectedCountry, setSelectedCountry] = useState(value||"");
9
+ if (input.field_type === 'short_text' || input.field_type === 'email') {
10
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: input.name, className: "block text-sm font-medium text-gray-700 mb-1", children: input.dispaly_name ? input.dispaly_name : input.name }), (0, jsx_runtime_1.jsx)("input", { type: input.field_type === 'short_text' ||
11
+ input.field_type === 'email'
12
+ ? 'text'
13
+ : input.field_type, id: input._id, name: input.field_id, value: value, onChange: handleChange, formNoValidate: true, placeholder: input.placeholder, disabled: disabled, className: `w-full px-4 py-2 h-9 text-sm rounded-lg border ${disabled ? 'text-slate-400 border-zinc-200 bg-zinc-50' : 'bg-white'} ${error
14
+ ? 'border-red-500 focus:ring-red-500'
15
+ : 'border-gray-300 focus:ring-blue-500'} focus:outline-none focus:ring-2 focus:border-transparent` }), error && (0, jsx_runtime_1.jsx)("p", { className: "text-red-500 text-xs mt-1", children: error })] }));
16
+ }
17
+ else if (input.field_type === 'country') {
18
+ return ((0, jsx_runtime_1.jsx)(CountryDropdown_1.CountryDropdown, { disabled: disabled, countries: country_codes_flags_phone_codes_1.countries, value: value, onChange: (selectedValue) => {
19
+ const syntheticEvent = {
20
+ target: {
21
+ name: input.field_id,
22
+ value: selectedValue,
23
+ },
24
+ };
25
+ handleChange(syntheticEvent);
26
+ } })
27
+ // <CountryDropdown countries={countries}
28
+ // value={selectedCountry}
29
+ // />
30
+ // <div className="w-full">
31
+ // <label
32
+ // htmlFor={input.field_id}
33
+ // className="block text-sm font-medium text-gray-700 mb-1"
34
+ // >
35
+ // {input.display_name || 'Country'}
36
+ // </label>
37
+ // <select
38
+ // id={input._id}
39
+ // name={input.field_id}
40
+ // value={value}
41
+ // onChange={(e) =>
42
+ // handleChange(
43
+ // e as unknown as React.ChangeEvent<HTMLInputElement>
44
+ // )
45
+ // }
46
+ // className={`w-full px-2 py-2 h-9 text-sm rounded-lg border ${
47
+ // error
48
+ // ? 'border-red-500 focus:ring-red-500'
49
+ // : 'border-gray-300 focus:ring-blue-500'
50
+ // } focus:outline-none focus:ring-2 focus:border-transparent bg-white`}
51
+ // >
52
+ // <option
53
+ // value=""
54
+ // disabled
55
+ // className="bg-[red] mt-10 text-[#fff]"
56
+ // >
57
+ // {input.placeholder || 'Select a country'}
58
+ // </option>
59
+ // {countries.map((c) => (
60
+ // <option key={c.code} value={c.name}>
61
+ // {c.name}
62
+ // </option>
63
+ // ))}
64
+ // </select>
65
+ // {error && <p className="text-red-500 text-xs mt-1">{error}</p>}
66
+ // </div>
67
+ );
68
+ }
69
+ else if (input.field_type === 'long_text') {
70
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: input.name, className: "block text-sm font-medium text-gray-700 mb-1", children: input.dispaly_name ? input.dispaly_name : input.name }), (0, jsx_runtime_1.jsx)("textarea", { name: input.field_id, value: value, className: `w-full px-4 py-2 h-32 text-sm rounded-lg border ${disabled ? 'text-slate-400 border-zinc-200 bg-zinc-50' : 'bg-white'} ${error
71
+ ? 'border-red-500 focus:ring-red-500'
72
+ : 'border-gray-300 focus:ring-blue-500'} focus:outline-none focus:ring-2 focus:border-transparent`, onChange: handleChange }), error && (0, jsx_runtime_1.jsx)("p", { className: "text-red-500 text-xs mt-1", children: error })] }));
73
+ }
74
+ else if (input.field_type === 'phone_number') {
75
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "w-full", children: [(0, jsx_runtime_1.jsx)("label", { htmlFor: input.name, className: "block text-sm font-medium text-gray-700 mb-1", children: input.dispaly_name ? input.dispaly_name : input.name }), (0, jsx_runtime_1.jsx)("input", { id: input._id, name: input.field_id, value: value, onChange: handleChange, formNoValidate: true, placeholder: input.placeholder, disabled: disabled, maxLength: 15, className: `w-full px-4 py-2 h-9 text-sm rounded-lg border ${disabled ? 'text-slate-400 border-zinc-200 bg-zinc-50' : 'bg-white'} ${error
76
+ ? 'border-red-500 focus:ring-red-500'
77
+ : 'border-gray-300 focus:ring-blue-500'} focus:outline-none focus:ring-2 focus:border-transparent` }), error && (0, jsx_runtime_1.jsx)("p", { className: "text-red-500 text-xs mt-1", children: error })] }));
78
+ }
79
+ };
80
+ exports.InputField = InputField;
@@ -0,0 +1,126 @@
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
+ const jsx_runtime_1 = require("react/jsx-runtime");
37
+ const react_1 = __importStar(require("react"));
38
+ const pikaicons_react_1 = require("./assets/icons/pikaicons-react");
39
+ const react_syntax_highlighter_1 = require("react-syntax-highlighter");
40
+ const prism_1 = require("react-syntax-highlighter/dist/esm/styles/prism");
41
+ require("./global.css");
42
+ const Markdown = () => {
43
+ const [markdown] = react_1.default.useState('table');
44
+ const [copied, setCopied] = (0, react_1.useState)(false);
45
+ const codeString = `
46
+ import requests
47
+
48
+ response = requests.get("https://api.example.com/data") # Replace with a real API endpoint
49
+ if response.status_code == 200:
50
+ data = response.json()
51
+ print(data)
52
+ else:
53
+ print(f"Failed to fetch data: {response.status_code}")
54
+ `;
55
+ const handleCopy = async () => {
56
+ try {
57
+ await navigator.clipboard.writeText(codeString);
58
+ setCopied(true);
59
+ setTimeout(() => setCopied(false), 2000);
60
+ }
61
+ catch (err) {
62
+ console.error('Copy failed', err);
63
+ }
64
+ };
65
+ const nestedItems = ['Nested item 1', 'Nested item 2', 'Nested item 3'];
66
+ const columns = [
67
+ 'ID',
68
+ 'Name',
69
+ 'Email',
70
+ 'Phone',
71
+ 'Company',
72
+ 'Country',
73
+ 'Status',
74
+ 'Date',
75
+ 'ID',
76
+ 'Name',
77
+ 'Email',
78
+ 'Phone',
79
+ 'Company',
80
+ 'Country',
81
+ 'Status',
82
+ 'Date',
83
+ ];
84
+ const data = Array.from({ length: 20 }, (_, i) => ({
85
+ id: i + 1,
86
+ name: `User ${i + 1}`,
87
+ email: `user${i + 1}@example.com`,
88
+ phone: `+123456789${i}`,
89
+ company: `Company ${i % 10}`,
90
+ country: `Country ${i % 5}`,
91
+ status: i % 2 === 0 ? 'Active' : 'Inactive',
92
+ date: `2025-05-${(i % 30) + 1}`,
93
+ id2: i + 1,
94
+ name2: `User ${i + 1}`,
95
+ email2: `user${i + 1}@example.com`,
96
+ phone2: `+123456789${i}`,
97
+ company2: `Company ${i % 10}`,
98
+ country2: `Country ${i % 5}`,
99
+ status2: i % 2 === 0 ? 'Active' : 'Inactive',
100
+ date2: `2025-05-${(i % 30) + 1}`,
101
+ }));
102
+ return ((0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-start gap-1.5 w-full", children: (0, jsx_runtime_1.jsx)("div", { className: "flex items-start w-full", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-2 w-[90%] rounded-lg overflow-hidden", children: [(0, jsx_runtime_1.jsxs)("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 items-center justify-center p-[5px] rounded-full bg-gradient-to-r from-[#564CFF] via-[#EB582E] to-[#ECD906]", children: (0, jsx_runtime_1.jsx)(pikaicons_react_1.PiSparkleAi01Solid, { className: "w-[16px] h-[16px] text-white" }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "text-sm font-medium text-[#020618]", children: "Support Agent" }), (0, jsx_runtime_1.jsx)("div", { className: "text-xs text-[#62748E]", children: "Just now" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col items-start gap-3 px-9 w-full", children: [markdown == 'bold' ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full -mt-[1px] text-sm font-bold text-[#020618]", children: "Hello! How can I help you today?" })) : null, markdown == 'italic' ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full -mt-[1px] text-sm italic text-[#020618]", children: "Hello! How can I help you today?" })) : null, markdown == 'bold-italic' ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full -mt-[1px] text-sm font-bold italic text-[#020618]", children: "Hello! How can I help you today?" })) : null, markdown == 'cross-text' ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full -mt-[1px] text-sm line-through text-[#020618]", children: "Hello! How can I help you today?" })) : null, markdown == 'yellow-marked-text' ? ((0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-3 w-full p-4 bg-[#fef3c6] border-l-4 border-[#e17100] rounded-r-lg", children: (0, jsx_runtime_1.jsx)("span", { className: "text-[#020618] text-sm leading-5", children: "Hello! How can I help you today?" }) })) : null, markdown == 'grey-marked-text' ? ((0, jsx_runtime_1.jsx)("div", { className: "flex items-start gap-3 w-full p-4 bg-[#F4F4F5] border-l-4 border-[#52525C] rounded-r-lg", children: (0, jsx_runtime_1.jsx)("span", { className: "text-[#020618] text-sm leading-5", children: "Hello! How can I help you today?" }) })) : null, markdown == 'key-texts' ? ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center w-max py-1 px-2 rounded-md bg-[#F4F4F5]", children: (0, jsx_runtime_1.jsx)("span", { className: "text-[#314158] text-sm leading-5", children: `api_key: "sk_abcdef1234567890"` }) })) : null, markdown == 'code-snippet' ? ((0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative' }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: handleCopy, style: {
103
+ position: 'absolute',
104
+ top: '10px',
105
+ right: '10px',
106
+ cursor: 'pointer',
107
+ zIndex: 1,
108
+ }, children: copied ? ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiCopyCopiedStroke, { className: "h-3.5 w-3.5" })) : ((0, jsx_runtime_1.jsx)(pikaicons_react_1.PiCopyDefaultStroke, { className: "h-3.5 w-3.5" })) }), (0, jsx_runtime_1.jsx)(react_syntax_highlighter_1.Prism, { customStyle: {
109
+ width: '100%',
110
+ borderRadius: '8px',
111
+ fontSize: '12px',
112
+ }, showLineNumbers: true, lineProps: {
113
+ style: {
114
+ display: 'block',
115
+ backgroundColor: '#F4F4F5',
116
+ fontSize: '12px',
117
+ },
118
+ }, codeTagProps: {
119
+ style: {
120
+ backgroundColor: '#F4F4F5',
121
+ padding: '0px',
122
+ fontSize: '12px',
123
+ },
124
+ }, PreTag: "div", wrapLongLines: true, wrapLines: true, className: "w-full bg-[#F4F4F5] text-wrap text-xs border border-[#E4E7EC] rounded-lg", language: "python", style: prism_1.coy, children: codeString })] })) : null, markdown == 'unordered-list' ? ((0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Responsive design", (0, jsx_runtime_1.jsxs)("ul", { children: [(0, jsx_runtime_1.jsx)("li", { children: "Nested item 1" }), (0, jsx_runtime_1.jsx)("li", { children: "Nested item 2" }), (0, jsx_runtime_1.jsx)("li", { children: "Nested item 3" })] })] }), (0, jsx_runtime_1.jsx)("li", { children: "Real-time editing" }), (0, jsx_runtime_1.jsx)("li", { children: "WYSIWYG interface" }), (0, jsx_runtime_1.jsx)("li", { children: "Font styles and sizes" }), (0, jsx_runtime_1.jsx)("li", { children: "Font styles and sizes" }), (0, jsx_runtime_1.jsx)("li", { children: "Text color and highlighting" }), (0, jsx_runtime_1.jsx)("li", { children: "Text alignment" }), (0, jsx_runtime_1.jsx)("li", { children: "Bullet and numbered Lists" })] })) : null, markdown == 'ordered-list' ? ((0, jsx_runtime_1.jsxs)("ol", { children: [(0, jsx_runtime_1.jsxs)("li", { children: ["Responsive design", (0, jsx_runtime_1.jsxs)("ol", { children: [(0, jsx_runtime_1.jsx)("li", { children: "Nested item 1" }), (0, jsx_runtime_1.jsx)("li", { children: "Nested item 2" }), (0, jsx_runtime_1.jsx)("li", { children: "Nested item 3" })] })] }), (0, jsx_runtime_1.jsx)("li", { children: "Real-time editing" }), (0, jsx_runtime_1.jsx)("li", { children: "WYSIWYG interface" }), (0, jsx_runtime_1.jsx)("li", { children: "Font styles and sizes" }), (0, jsx_runtime_1.jsx)("li", { children: "Text color and highlighting" }), (0, jsx_runtime_1.jsx)("li", { children: "Text alignment" }), (0, jsx_runtime_1.jsx)("li", { children: "Bullet and numbered Lists" })] })) : null, markdown == 'link-text' ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full -mt-[1px] text-sm text-[#4B2FFF] underline cursor-pointer hover:text-[#3517f7]", children: (0, jsx_runtime_1.jsx)("a", { href: "https://www.example.com", children: "Hello! How can I help you today?" }) })) : null, markdown == 'table' ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full h-[300px] overflow-auto rounded-lg border border-gray-300", children: (0, jsx_runtime_1.jsxs)("table", { className: "w-full border-collapse min-w-full text-sm", children: [(0, jsx_runtime_1.jsx)("thead", { className: "bg-gray-100 sticky top-0 z-10", children: (0, jsx_runtime_1.jsx)("tr", { children: columns.map((col, i) => ((0, jsx_runtime_1.jsx)("th", { className: "px-4 py-2 text-left border-b border-gray-300 whitespace-nowrap text-sm", children: col }, i))) }) }), (0, jsx_runtime_1.jsx)("tbody", { children: data.map((row, i) => ((0, jsx_runtime_1.jsx)("tr", { className: "bg-white", children: Object.entries(row).map(([key, value]) => ((0, jsx_runtime_1.jsx)("td", { className: "px-4 py-2 border-b whitespace-nowrap texrt-sm", children: value }, key))) }, i))) })] }) })) : null, markdown == 'image' ? ((0, jsx_runtime_1.jsx)("div", { className: "w-full -mt-[1px] text-sm text-[#020618]", children: (0, jsx_runtime_1.jsx)("img", { src: "https://img.freepik.com/free-photo/3d-rendering-luxury-business-meeting-working-room-executive-office_105762-1993.jpg?ga=GA1.1.30189705.1747290318&semt=ais_hybrid&w=740", alt: "Placeholder", className: "rounded-lg" }) })) : null, markdown == 'image-skeleton' ? ((0, jsx_runtime_1.jsxs)("div", { className: "w-[250px] h-[250px] flex flex-col justify-center items-center gap-1 bg-[#F4F4F5] rounded-[10px]", children: [(0, jsx_runtime_1.jsx)(pikaicons_react_1.PiPhotoImageDefaultSolid, { className: "text-[#90A1B9]" }), (0, jsx_runtime_1.jsx)("span", { className: "text-sm font-normal leading-5 text-[#45556C]", children: "No preview available" })] })) : null, markdown == 'rule-text' ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col w-full max-w-[533px] items-start gap-2 pr-0 py-0", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-full h-px bg-gray-200" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full", children: (0, jsx_runtime_1.jsx)("ol", { children: (0, jsx_runtime_1.jsxs)("li", { children: ["Responsive design", (0, jsx_runtime_1.jsx)("ol", { children: nestedItems.map((item, index) => ((0, jsx_runtime_1.jsx)("li", { className: "flex-1 text-sm text-[#1a1a1a] font-regular", children: item }, index))) })] }) }) }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-px bg-gray-200" })] })) : null, markdown == 'rule-without-text' ? ((0, jsx_runtime_1.jsxs)("div", { className: "flex flex-col w-full max-w-[533px] items-start gap-2 pr-0 py-0", children: [(0, jsx_runtime_1.jsx)("div", { className: "w-full h-px bg-gray-200" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-px bg-gray-200" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-px bg-gray-200" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-px bg-gray-200" }), (0, jsx_runtime_1.jsx)("div", { className: "w-full h-px bg-gray-200" })] })) : null] })] }) }) }));
125
+ };
126
+ exports.default = Markdown;
package/out/Message.js ADDED
@@ -0,0 +1,197 @@
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.Message = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ /* eslint-disable @typescript-eslint/no-explicit-any */
9
+ const react_1 = require("react");
10
+ const pager_md_1 = __importDefault(require("./markdown/pager_md"));
11
+ const ReceivedMessage_1 = require("./ReceivedMessage");
12
+ const widgetConfigStore2_1 = require("./widgetConfigStore2");
13
+ const widgetStore_1 = require("./widgetStore");
14
+ // function shouldTriggerExit(message: any): boolean {
15
+ // if (
16
+ // message?.output?.[0]?.value?.value
17
+ // ?.toLowerCase()
18
+ // ?.includes('we are exiting from the conversation now')
19
+ // ) {
20
+ // return true
21
+ // }
22
+ // return false
23
+ // }
24
+ function shouldTriggerExit(message) {
25
+ if (message?.output[0]?.response_type === 'session_expired' ||
26
+ message?.output?.[0]?.value?.value
27
+ ?.toLowerCase()
28
+ ?.includes('we are exiting from the conversation now')) {
29
+ return true;
30
+ }
31
+ return false;
32
+ }
33
+ const Message = ({ messageResponse, sendFeedback, sendMessage, setMessages, }) => {
34
+ console.log(messageResponse, 'messageResponse');
35
+ const { type, time, message } = messageResponse;
36
+ const [botStatus, setBotStatus] = (0, react_1.useState)(null);
37
+ const widget = (0, widgetConfigStore2_1.useWidgetData)();
38
+ (0, react_1.useEffect)(() => {
39
+ console.log('exit check var');
40
+ if (type === 'received' && shouldTriggerExit(message)) {
41
+ const exitLockKey = `CONVERSATION_EXIT_LOCK::${widget.data.id}`;
42
+ // Prevent multiple tabs from running exit logic
43
+ if (localStorage.getItem(exitLockKey)) {
44
+ console.log('Exit already handled by another tab');
45
+ return;
46
+ }
47
+ // Set lock
48
+ localStorage.setItem(exitLockKey, 'true');
49
+ widgetStore_1.widgetStore.trigger.handleExitChatState({ value: true });
50
+ const raw = localStorage.getItem(`CONVERSATION::${widget.data.id}`);
51
+ if (!raw) {
52
+ console.warn('No data found in CONVERSATION key');
53
+ return;
54
+ }
55
+ try {
56
+ const currentData = JSON.parse(raw);
57
+ const listRaw = localStorage.getItem(`CONVERSATION_LIST::${widget.data.id}`);
58
+ const currentList = listRaw ? JSON.parse(listRaw) : [];
59
+ currentList.push(currentData);
60
+ localStorage.setItem(`CONVERSATION_LIST::${widget.data.id}`, JSON.stringify(currentList));
61
+ localStorage.removeItem('CURRENT_CONVERSATION');
62
+ localStorage.removeItem(`CONVERSATION::${widget.data.id}`);
63
+ // Optional: clear lock after short delay
64
+ setTimeout(() => {
65
+ localStorage.removeItem(exitLockKey);
66
+ }, 100);
67
+ }
68
+ catch (error) {
69
+ console.error('Failed to parse localStorage data:', error);
70
+ }
71
+ }
72
+ }, []);
73
+ // useEffect(() => {
74
+ // console.log('Exit triggered')
75
+ // if (type === 'received' && shouldTriggerExit(message)) {
76
+ // const exitLockKey = `CONVERSATION_EXIT_LOCK::${widget.data.id}`
77
+ // // Prevent multiple tabs from running exit logic
78
+ // if (localStorage.getItem(exitLockKey)) {
79
+ // console.log('Exit already handled by another tab')
80
+ // return
81
+ // }
82
+ // // Set lock
83
+ // localStorage.setItem(exitLockKey, 'true')
84
+ // widgetStore.trigger.handleExitChatState({ value: true })
85
+ // const raw = localStorage.getItem(`CONVERSATION::${widget.data.id}`)
86
+ // if (!raw) {
87
+ // console.warn('No data found in CONVERSATION key')
88
+ // return
89
+ // }
90
+ // try {
91
+ // const currentData = JSON.parse(raw)
92
+ // const listRaw = localStorage.getItem(
93
+ // `CONVERSATION_LIST::${widget.data.id}`
94
+ // )
95
+ // const currentList = listRaw ? JSON.parse(listRaw) : []
96
+ // currentList.push(currentData)
97
+ // localStorage.setItem(
98
+ // `CONVERSATION_LIST::${widget.data.id}`,
99
+ // JSON.stringify(currentList)
100
+ // )
101
+ // localStorage.removeItem('CURRENT_CONVERSATION')
102
+ // // Optional: clear lock after short delay
103
+ // setTimeout(() => {
104
+ // localStorage.removeItem(exitLockKey)
105
+ // }, 5000)
106
+ // } catch (error) {
107
+ // console.error('Failed to parse localStorage data:', error)
108
+ // }
109
+ // }
110
+ // }, [type, message, widget.data.id])
111
+ // useEffect(() => {
112
+ // console.log('Exit triggered')
113
+ // if (type === 'received' && shouldTriggerExit(message)) {
114
+ // widgetStore.trigger.handleExitChatState({ value: true })
115
+ // const raw = localStorage.getItem(`CONVERSATION::${widget.data.id}`)
116
+ // if (!raw) {
117
+ // console.warn('No data found in DUMMY key')
118
+ // return
119
+ // }
120
+ // try {
121
+ // const currentData = JSON.parse(raw)
122
+ // // Step 2: Get existing array from 'DUMMY_LIST'
123
+ // const listRaw = localStorage.getItem(
124
+ // `CONVERSATION_LIST::${widget.data.id}`
125
+ // )
126
+ // const currentList = listRaw ? JSON.parse(listRaw) : []
127
+ // // Step 3: Append the current object
128
+ // currentList.push(currentData)
129
+ // // Step 4: Save back to 'DUMMY_LIST'
130
+ // localStorage.setItem(
131
+ // `CONVERSATION_LIST::${widget.data.id}`,
132
+ // JSON.stringify(currentList)
133
+ // )
134
+ // localStorage.removeItem('CURRENT_CONVERSATION')
135
+ // // Step 5: Perform other exit actions
136
+ // // widgetFetchStore2.trigger.exitConversation()
137
+ // // Optional: Also update widget state
138
+ // // widgetStore.send({ type: 'handleExitChatState', value: true })
139
+ // } catch (error) {
140
+ // console.error('Failed to parse localStorage data:', error)
141
+ // }
142
+ // }
143
+ // }, [type, message, widget.data.id])
144
+ (0, react_1.useEffect)(() => {
145
+ const handleStorageChange = () => {
146
+ const raw = window.localStorage.getItem(`CONVERSATION::${widget.data.id}`);
147
+ if (raw) {
148
+ try {
149
+ const parsed = JSON.parse(raw);
150
+ const filtered = parsed.events.filter((event) => event.type === 'sent' || event.type === 'received');
151
+ console.log('event listener called (filtered):', filtered);
152
+ setMessages(filtered);
153
+ }
154
+ catch (err) {
155
+ console.error('Failed to parse localStorage on storage event:', err);
156
+ }
157
+ }
158
+ };
159
+ window.addEventListener('storage', handleStorageChange);
160
+ return () => {
161
+ window.removeEventListener('storage', handleStorageChange);
162
+ };
163
+ }, []);
164
+ console.log('botStatus', botStatus);
165
+ (0, react_1.useEffect)(() => {
166
+ const outputType = message?.output?.[0]?.type;
167
+ console.log('botStatus', outputType);
168
+ // If it's a status message
169
+ if (['thinking', 'finalizing_output', 'progress_done'].includes(outputType)) {
170
+ setBotStatus(outputType); // <-- only latest status
171
+ return;
172
+ }
173
+ // If it's the real bot message (received)
174
+ if (type === 'received') {
175
+ setBotStatus(null); // <-- clear status
176
+ }
177
+ }, [message, type]);
178
+ const outputType = message?.output?.[0]?.type;
179
+ const isBlockedType = [
180
+ 'thinking',
181
+ 'finalizing_output',
182
+ 'progress_done',
183
+ ].includes(outputType);
184
+ const isStatus = [
185
+ 'thinking',
186
+ 'finalizing_output',
187
+ 'progress_done',
188
+ ].includes(outputType);
189
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [type === 'received' && isStatus ? null : null, type === 'received' && !isBlockedType ? ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: (0, jsx_runtime_1.jsx)(ReceivedMessage_1.ReceivedMessage, { message: message, sendFeedback: sendFeedback, sendMessage: sendMessage, time: time }) })) : type !== 'received' ? (
190
+ // Render user (sent) message
191
+ (0, jsx_runtime_1.jsx)("div", { className: "flex flex-col items-end gap-2.5 px-5 py-0 relative self-stretch w-full animate-slide-in-right", children: (0, jsx_runtime_1.jsx)("div", { className: "w-auto max-w-[80%] items-end gap-1 flex flex-col relative", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-end items-end w-fit gap-1 relative", children: (0, jsx_runtime_1.jsx)("div", { className: `flex flex-1 grow text-[${widget?.data?.user_message_text_color}] items-start gap-2.5 px-3.5 py-2.5 relative rounded-lg`, style: {
192
+ background: widget?.data?.secondary_color,
193
+ color: widget?.data
194
+ ?.user_message_text_color,
195
+ }, children: (0, jsx_runtime_1.jsx)("div", { className: "relative mt-[-1px] text-sm", children: (0, jsx_runtime_1.jsx)(pager_md_1.default, { mdText: message.input }) }) }) }) }) })) : null] }));
196
+ };
197
+ exports.Message = Message;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });