aizek-chatbot 1.0.5 → 1.0.6
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.
- package/dist/index.cjs +184 -245
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +174 -218
- package/dist/index.mjs.map +1 -1
- package/package.json +46 -46
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import remarkGfm from "remark-gfm";
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useState, useEffect, useRef } from 'react';
|
|
3
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
4
|
+
import OpenAI from 'openai';
|
|
5
|
+
import ReactMarkdown from 'react-markdown';
|
|
6
|
+
import remarkGfm from 'remark-gfm';
|
|
8
7
|
|
|
9
8
|
// src/utils/cx.ts
|
|
10
9
|
function cx(...args) {
|
|
@@ -19,18 +18,18 @@ var base = {
|
|
|
19
18
|
lineHeight: 1,
|
|
20
19
|
transition: "background-color .2s ease, color .2s ease, border-color .2s ease",
|
|
21
20
|
outline: "none",
|
|
22
|
-
cursor: "pointer"
|
|
21
|
+
cursor: "pointer"
|
|
23
22
|
};
|
|
24
23
|
var sizes = {
|
|
25
24
|
sm: { height: 36, padding: "0 12px", fontSize: 14 },
|
|
26
25
|
md: { height: 40, padding: "0 16px", fontSize: 16 },
|
|
27
|
-
lg: { height: 44, padding: "0 20px", fontSize: 18 }
|
|
26
|
+
lg: { height: 44, padding: "0 20px", fontSize: 18 }
|
|
28
27
|
};
|
|
29
28
|
var palette = {
|
|
30
29
|
brand: {
|
|
31
30
|
primary: "#2563eb",
|
|
32
|
-
primaryHover: "#1d4ed8"
|
|
33
|
-
}
|
|
31
|
+
primaryHover: "#1d4ed8"
|
|
32
|
+
}
|
|
34
33
|
};
|
|
35
34
|
function styleFor(variant) {
|
|
36
35
|
switch (variant) {
|
|
@@ -38,45 +37,45 @@ function styleFor(variant) {
|
|
|
38
37
|
return {
|
|
39
38
|
background: "transparent",
|
|
40
39
|
color: palette.brand.primary,
|
|
41
|
-
border: `1px solid ${palette.brand.primary}
|
|
40
|
+
border: `1px solid ${palette.brand.primary}`
|
|
42
41
|
};
|
|
43
42
|
case "ghost":
|
|
44
43
|
return {
|
|
45
44
|
background: "transparent",
|
|
46
45
|
color: palette.brand.primary,
|
|
47
|
-
border: "1px solid transparent"
|
|
46
|
+
border: "1px solid transparent"
|
|
48
47
|
};
|
|
49
48
|
default:
|
|
50
49
|
return {
|
|
51
50
|
background: palette.brand.primary,
|
|
52
51
|
color: "#fff",
|
|
53
|
-
border: "1px solid transparent"
|
|
52
|
+
border: "1px solid transparent"
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
}
|
|
57
|
-
var Button = React.forwardRef(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
variant === "primary"
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
56
|
+
var Button = React.forwardRef(
|
|
57
|
+
({ variant = "primary", size = "md", style, className, onMouseEnter, onMouseLeave, ...props }, ref) => {
|
|
58
|
+
const [hover, setHover] = React.useState(false);
|
|
59
|
+
const hoverStyle = variant === "primary" ? { background: hover ? palette.brand.primaryHover : palette.brand.primary } : variant === "outline" ? { borderColor: hover ? palette.brand.primaryHover : palette.brand.primary } : { background: hover ? "rgba(37, 99, 235, 0.08)" : "transparent" };
|
|
60
|
+
return /* @__PURE__ */ jsx(
|
|
61
|
+
"button",
|
|
62
|
+
{
|
|
63
|
+
ref,
|
|
64
|
+
className: cx("rui-btn", className),
|
|
65
|
+
style: { ...base, ...sizes[size], ...styleFor(variant), ...hover ? hoverStyle : {}, ...style },
|
|
66
|
+
onMouseEnter: (e) => {
|
|
67
|
+
setHover(true);
|
|
68
|
+
onMouseEnter?.(e);
|
|
69
|
+
},
|
|
70
|
+
onMouseLeave: (e) => {
|
|
71
|
+
setHover(false);
|
|
72
|
+
onMouseLeave?.(e);
|
|
73
|
+
},
|
|
74
|
+
...props
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
);
|
|
80
79
|
Button.displayName = "Button";
|
|
81
80
|
var useChatbot = (options = {}) => {
|
|
82
81
|
const { mcpUrl, apiKey } = options;
|
|
@@ -92,7 +91,7 @@ var useChatbot = (options = {}) => {
|
|
|
92
91
|
id: generateId(),
|
|
93
92
|
content,
|
|
94
93
|
role,
|
|
95
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
94
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
96
95
|
};
|
|
97
96
|
setMessages((prev) => [...prev, newMessage]);
|
|
98
97
|
return newMessage;
|
|
@@ -114,11 +113,13 @@ var useChatbot = (options = {}) => {
|
|
|
114
113
|
require_approval: "never",
|
|
115
114
|
headers: {
|
|
116
115
|
Authorization: `Bearer ${options.userToken}`,
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
brandId: "c5bfc750-69fd-4653-8dbb-f01614bc3319",
|
|
117
|
+
"privy-token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlNLb3JzbjRsMnJWSllrNEFrd0EtY0NaVVY1M0ticUQ2eHZ6UTNPeDdsY3cifQ.eyJzaWQiOiJjbWdqN25yb3EwMWRqbGEwY2M3a3hoamVzIiwiaXNzIjoicHJpdnkuaW8iLCJpYXQiOjE3NjAwMTMzMTYsImF1ZCI6ImNsc3U1eWM4NTA4d2hpMGZhZWR1a2Uxd3MiLCJzdWIiOiJkaWQ6cHJpdnk6Y2x0Y3d4MTNuMGkwNTEyeXRmNWI5d3NzdSIsImV4cCI6MTc2MDAxNjkxNn0.qzUpTuk5e8W0mggf4FTAAP3zZyjJjwpMi-QXU_2pLO9kgfMV5IYPzymR9XjTEBMfJxgC9dApMDvOAX8MvX7URw"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
119
120
|
],
|
|
120
121
|
input: message,
|
|
121
|
-
previous_response_id: responseId || void 0
|
|
122
|
+
previous_response_id: responseId || void 0
|
|
122
123
|
});
|
|
123
124
|
} else {
|
|
124
125
|
resp = await client.responses.create({
|
|
@@ -129,10 +130,14 @@ var useChatbot = (options = {}) => {
|
|
|
129
130
|
server_label: "aizek-mcp",
|
|
130
131
|
server_url: mcpUrl,
|
|
131
132
|
require_approval: "never",
|
|
132
|
-
|
|
133
|
+
headers: {
|
|
134
|
+
brandId: "c5bfc750-69fd-4653-8dbb-f01614bc3319",
|
|
135
|
+
"privy-token": "eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlNLb3JzbjRsMnJWSllrNEFrd0EtY0NaVVY1M0ticUQ2eHZ6UTNPeDdsY3cifQ.eyJzaWQiOiJjbWdqN25yb3EwMWRqbGEwY2M3a3hoamVzIiwiaXNzIjoicHJpdnkuaW8iLCJpYXQiOjE3NjAwMTMzMTYsImF1ZCI6ImNsc3U1eWM4NTA4d2hpMGZhZWR1a2Uxd3MiLCJzdWIiOiJkaWQ6cHJpdnk6Y2x0Y3d4MTNuMGkwNTEyeXRmNWI5d3NzdSIsImV4cCI6MTc2MDAxNjkxNn0.qzUpTuk5e8W0mggf4FTAAP3zZyjJjwpMi-QXU_2pLO9kgfMV5IYPzymR9XjTEBMfJxgC9dApMDvOAX8MvX7URw"
|
|
136
|
+
}
|
|
137
|
+
}
|
|
133
138
|
],
|
|
134
139
|
input: message,
|
|
135
|
-
previous_response_id: responseId || void 0
|
|
140
|
+
previous_response_id: responseId || void 0
|
|
136
141
|
});
|
|
137
142
|
}
|
|
138
143
|
setResponseId(resp.id);
|
|
@@ -167,7 +172,7 @@ var useChatbot = (options = {}) => {
|
|
|
167
172
|
messages,
|
|
168
173
|
isLoading,
|
|
169
174
|
sendMessage,
|
|
170
|
-
addMessage
|
|
175
|
+
addMessage
|
|
171
176
|
};
|
|
172
177
|
};
|
|
173
178
|
|
|
@@ -178,8 +183,8 @@ var fetchChatWidgetSettings = async (clientId) => {
|
|
|
178
183
|
const response = await fetch(`${API_BASE_URL}/ChatWidgetSettings/GetByClientId?client_id=${clientId}`, {
|
|
179
184
|
method: "GET",
|
|
180
185
|
headers: {
|
|
181
|
-
"Content-Type": "application/json"
|
|
182
|
-
}
|
|
186
|
+
"Content-Type": "application/json"
|
|
187
|
+
}
|
|
183
188
|
});
|
|
184
189
|
if (!response.ok) {
|
|
185
190
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
@@ -196,9 +201,9 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
196
201
|
return null;
|
|
197
202
|
}
|
|
198
203
|
const buttonSizeMap = {
|
|
199
|
-
small: "sm",
|
|
200
|
-
medium: "md",
|
|
201
|
-
large: "lg"
|
|
204
|
+
"small": "sm",
|
|
205
|
+
"medium": "md",
|
|
206
|
+
"large": "lg"
|
|
202
207
|
};
|
|
203
208
|
return {
|
|
204
209
|
welcomeMessage: apiSettings.welcome_message,
|
|
@@ -212,7 +217,7 @@ var mapApiSettingsToConfig = (apiSettings) => {
|
|
|
212
217
|
initialOpen: apiSettings.initial_open,
|
|
213
218
|
headerBackground: apiSettings.header_background,
|
|
214
219
|
companyLogo: apiSettings.company_logo || void 0,
|
|
215
|
-
companyName: apiSettings.company_name
|
|
220
|
+
companyName: apiSettings.company_name
|
|
216
221
|
};
|
|
217
222
|
};
|
|
218
223
|
|
|
@@ -226,29 +231,27 @@ var getMessageBubbleStyles = (isUser) => ({
|
|
|
226
231
|
lineHeight: 1.4,
|
|
227
232
|
fontSize: "14px",
|
|
228
233
|
position: "relative",
|
|
229
|
-
...
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
marginRight: "auto",
|
|
242
|
-
}),
|
|
234
|
+
...isUser ? {
|
|
235
|
+
background: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
236
|
+
color: "#ffffff",
|
|
237
|
+
marginLeft: "auto",
|
|
238
|
+
marginRight: "0"
|
|
239
|
+
} : {
|
|
240
|
+
background: "#f8fafc",
|
|
241
|
+
color: "#334155",
|
|
242
|
+
border: "1px solid #e2e8f0",
|
|
243
|
+
marginLeft: "0",
|
|
244
|
+
marginRight: "auto"
|
|
245
|
+
}
|
|
243
246
|
});
|
|
244
247
|
var getTimeStyles = (isUser) => ({
|
|
245
248
|
fontSize: "11px",
|
|
246
249
|
opacity: 0.7,
|
|
247
250
|
marginTop: "4px",
|
|
248
|
-
textAlign: isUser ? "right" : "left"
|
|
251
|
+
textAlign: isUser ? "right" : "left"
|
|
249
252
|
});
|
|
250
253
|
var getMarkdownStyles = () => ({
|
|
251
|
-
lineHeight: 1.6
|
|
254
|
+
lineHeight: 1.6
|
|
252
255
|
});
|
|
253
256
|
var getMarkdownElementStyles = (isUser) => `
|
|
254
257
|
.markdown-content p {
|
|
@@ -409,7 +412,7 @@ var getMessageContainerStyles = (isUser) => ({
|
|
|
409
412
|
display: "flex",
|
|
410
413
|
flexDirection: "column",
|
|
411
414
|
alignItems: isUser ? "flex-end" : "flex-start",
|
|
412
|
-
width: "100%"
|
|
415
|
+
width: "100%"
|
|
413
416
|
});
|
|
414
417
|
|
|
415
418
|
// src/styles/inputStyles.ts
|
|
@@ -420,7 +423,7 @@ var getInputContainerStyles = () => ({
|
|
|
420
423
|
padding: "16px",
|
|
421
424
|
background: "#ffffff",
|
|
422
425
|
borderTop: "1px solid #e2e8f0",
|
|
423
|
-
borderRadius: "0 0 12px 12px"
|
|
426
|
+
borderRadius: "0 0 12px 12px"
|
|
424
427
|
});
|
|
425
428
|
var getTextareaStyles = (isLoading) => ({
|
|
426
429
|
flex: 1,
|
|
@@ -437,12 +440,10 @@ var getTextareaStyles = (isLoading) => ({
|
|
|
437
440
|
fontFamily: "inherit",
|
|
438
441
|
background: "#f8fafc",
|
|
439
442
|
color: "#334155",
|
|
440
|
-
...
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
: {}),
|
|
443
|
+
...isLoading ? {
|
|
444
|
+
opacity: 0.6,
|
|
445
|
+
cursor: "not-allowed"
|
|
446
|
+
} : {}
|
|
446
447
|
});
|
|
447
448
|
var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
448
449
|
width: "44px",
|
|
@@ -456,7 +457,7 @@ var getSendButtonStyles = (isLoading, hasMessage) => ({
|
|
|
456
457
|
alignItems: "center",
|
|
457
458
|
justifyContent: "center",
|
|
458
459
|
transition: "all 0.2s ease",
|
|
459
|
-
fontSize: "16px"
|
|
460
|
+
fontSize: "16px"
|
|
460
461
|
});
|
|
461
462
|
|
|
462
463
|
// src/styles/headerStyles.ts
|
|
@@ -466,7 +467,7 @@ var getHeaderStyles = (headerBackground) => ({
|
|
|
466
467
|
color: "#ffffff",
|
|
467
468
|
display: "flex",
|
|
468
469
|
alignItems: "center",
|
|
469
|
-
gap: "12px"
|
|
470
|
+
gap: "12px"
|
|
470
471
|
});
|
|
471
472
|
var getLogoContainerStyles = () => ({
|
|
472
473
|
width: "40px",
|
|
@@ -477,34 +478,34 @@ var getLogoContainerStyles = () => ({
|
|
|
477
478
|
alignItems: "center",
|
|
478
479
|
justifyContent: "center",
|
|
479
480
|
fontSize: "18px",
|
|
480
|
-
overflow: "hidden"
|
|
481
|
+
overflow: "hidden"
|
|
481
482
|
});
|
|
482
483
|
var getLogoImageStyles = () => ({
|
|
483
484
|
width: "100%",
|
|
484
485
|
height: "100%",
|
|
485
486
|
objectFit: "cover",
|
|
486
|
-
borderRadius: "50%"
|
|
487
|
+
borderRadius: "50%"
|
|
487
488
|
});
|
|
488
489
|
var getLogoTextStyles = () => ({
|
|
489
490
|
fontSize: "16px",
|
|
490
|
-
fontWeight: "bold"
|
|
491
|
+
fontWeight: "bold"
|
|
491
492
|
});
|
|
492
493
|
var getCompanyNameStyles = () => ({
|
|
493
494
|
margin: 0,
|
|
494
495
|
fontSize: "16px",
|
|
495
|
-
fontWeight: 600
|
|
496
|
+
fontWeight: 600
|
|
496
497
|
});
|
|
497
498
|
var getStatusTextStyles = () => ({
|
|
498
499
|
margin: 0,
|
|
499
500
|
fontSize: "12px",
|
|
500
|
-
opacity: 0.8
|
|
501
|
+
opacity: 0.8
|
|
501
502
|
});
|
|
502
503
|
|
|
503
504
|
// src/styles/containerStyles.ts
|
|
504
505
|
var getButtonSizes = () => ({
|
|
505
506
|
sm: { width: "50px", height: "50px", fontSize: "20px" },
|
|
506
507
|
md: { width: "60px", height: "60px", fontSize: "24px" },
|
|
507
|
-
lg: { width: "70px", height: "70px", fontSize: "28px" }
|
|
508
|
+
lg: { width: "70px", height: "70px", fontSize: "28px" }
|
|
508
509
|
});
|
|
509
510
|
var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isOpen) => {
|
|
510
511
|
const buttonSizes = getButtonSizes();
|
|
@@ -527,7 +528,7 @@ var getFloatingButtonStyles = (buttonPosition, buttonSize, buttonBackground, isO
|
|
|
527
528
|
boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
|
|
528
529
|
transition: "all 0.3s ease",
|
|
529
530
|
zIndex: 1e3,
|
|
530
|
-
transform: isOpen ? "scale(0.9)" : "scale(1)"
|
|
531
|
+
transform: isOpen ? "scale(0.9)" : "scale(1)"
|
|
531
532
|
};
|
|
532
533
|
};
|
|
533
534
|
var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) => ({
|
|
@@ -541,7 +542,7 @@ var getChatContainerStyles = (buttonPosition, chatWidth, chatHeight, isOpen) =>
|
|
|
541
542
|
opacity: isOpen ? 1 : 0,
|
|
542
543
|
visibility: isOpen ? "visible" : "hidden",
|
|
543
544
|
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
544
|
-
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
|
|
545
|
+
transformOrigin: buttonPosition === "bottom-left" ? "bottom left" : "bottom right"
|
|
545
546
|
});
|
|
546
547
|
var getOverlayStyles = (isOpen) => ({
|
|
547
548
|
position: "fixed",
|
|
@@ -553,7 +554,7 @@ var getOverlayStyles = (isOpen) => ({
|
|
|
553
554
|
zIndex: 998,
|
|
554
555
|
opacity: isOpen ? 1 : 0,
|
|
555
556
|
visibility: isOpen ? "visible" : "hidden",
|
|
556
|
-
transition: "all 0.3s ease"
|
|
557
|
+
transition: "all 0.3s ease"
|
|
557
558
|
});
|
|
558
559
|
var getChatbotContainerStyles = () => ({
|
|
559
560
|
display: "flex",
|
|
@@ -563,7 +564,7 @@ var getChatbotContainerStyles = () => ({
|
|
|
563
564
|
borderRadius: "12px",
|
|
564
565
|
boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",
|
|
565
566
|
border: "1px solid #e2e8f0",
|
|
566
|
-
overflow: "hidden"
|
|
567
|
+
overflow: "hidden"
|
|
567
568
|
});
|
|
568
569
|
var getMessagesContainerStyles = () => ({
|
|
569
570
|
flex: 1,
|
|
@@ -572,7 +573,7 @@ var getMessagesContainerStyles = () => ({
|
|
|
572
573
|
display: "flex",
|
|
573
574
|
flexDirection: "column",
|
|
574
575
|
gap: "4px",
|
|
575
|
-
background: "#f8fafc"
|
|
576
|
+
background: "#f8fafc"
|
|
576
577
|
});
|
|
577
578
|
var getEmptyStateStyles = () => ({
|
|
578
579
|
display: "flex",
|
|
@@ -582,7 +583,7 @@ var getEmptyStateStyles = () => ({
|
|
|
582
583
|
height: "100%",
|
|
583
584
|
color: "#64748b",
|
|
584
585
|
textAlign: "center",
|
|
585
|
-
padding: "40px 20px"
|
|
586
|
+
padding: "40px 20px"
|
|
586
587
|
});
|
|
587
588
|
|
|
588
589
|
// src/styles/loadingStyles.ts
|
|
@@ -592,7 +593,7 @@ var getLoadingSpinnerStyles = () => ({
|
|
|
592
593
|
border: "2px solid transparent",
|
|
593
594
|
borderTop: "2px solid currentColor",
|
|
594
595
|
borderRadius: "50%",
|
|
595
|
-
animation: "spin 1s linear infinite"
|
|
596
|
+
animation: "spin 1s linear infinite"
|
|
596
597
|
});
|
|
597
598
|
var AizekChatBot = ({ clientId, userToken }) => {
|
|
598
599
|
const defaultConfig = {
|
|
@@ -607,7 +608,7 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
607
608
|
initialOpen: true,
|
|
608
609
|
headerBackground: "linear-gradient(135deg, #667eea 0%, #764ba2 100%)",
|
|
609
610
|
companyLogo: void 0,
|
|
610
|
-
companyName: "AI Asistan"
|
|
611
|
+
companyName: "AI Asistan"
|
|
611
612
|
};
|
|
612
613
|
const [config, setConfig] = useState(defaultConfig);
|
|
613
614
|
const [isConfigLoading, setIsConfigLoading] = useState(true);
|
|
@@ -652,34 +653,21 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
652
653
|
}, [messages]);
|
|
653
654
|
const MessageBubble = ({ message }) => {
|
|
654
655
|
const isUser = message.role === "user";
|
|
655
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
656
|
-
style:
|
|
657
|
-
children: [
|
|
658
|
-
/* @__PURE__ */ jsx("style", { children:
|
|
659
|
-
/* @__PURE__ */
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
children: /* @__PURE__ */ jsx(TypingDots, {}),
|
|
671
|
-
}),
|
|
672
|
-
],
|
|
673
|
-
}),
|
|
674
|
-
/* @__PURE__ */ jsx("div", {
|
|
675
|
-
style: getTimeStyles(isUser),
|
|
676
|
-
children: message.timestamp.toLocaleTimeString("tr-TR", {
|
|
677
|
-
hour: "2-digit",
|
|
678
|
-
minute: "2-digit",
|
|
679
|
-
}),
|
|
680
|
-
}),
|
|
681
|
-
],
|
|
682
|
-
});
|
|
656
|
+
return /* @__PURE__ */ jsxs("div", { style: getMessageContainerStyles(isUser), children: [
|
|
657
|
+
/* @__PURE__ */ jsx("style", { children: getMarkdownElementStyles(isUser) }),
|
|
658
|
+
/* @__PURE__ */ jsxs("div", { style: getMessageBubbleStyles(isUser), children: [
|
|
659
|
+
/* @__PURE__ */ jsx("div", { style: getMarkdownStyles(), className: "markdown-content", children: /* @__PURE__ */ jsx(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content }) }),
|
|
660
|
+
message.isTyping && /* @__PURE__ */ jsx("div", { style: {
|
|
661
|
+
display: "inline-flex",
|
|
662
|
+
alignItems: "center",
|
|
663
|
+
marginLeft: "8px"
|
|
664
|
+
}, children: /* @__PURE__ */ jsx(TypingDots, {}) })
|
|
665
|
+
] }),
|
|
666
|
+
/* @__PURE__ */ jsx("div", { style: getTimeStyles(isUser), children: message.timestamp.toLocaleTimeString("tr-TR", {
|
|
667
|
+
hour: "2-digit",
|
|
668
|
+
minute: "2-digit"
|
|
669
|
+
}) })
|
|
670
|
+
] });
|
|
683
671
|
};
|
|
684
672
|
const TypingDots = () => {
|
|
685
673
|
const [dots, setDots] = useState("");
|
|
@@ -719,20 +707,22 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
719
707
|
textarea.style.height = "auto";
|
|
720
708
|
textarea.style.height = Math.min(textarea.scrollHeight, 120) + "px";
|
|
721
709
|
};
|
|
722
|
-
return /* @__PURE__ */ jsxs("form", {
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
/* @__PURE__ */ jsx("textarea", {
|
|
710
|
+
return /* @__PURE__ */ jsxs("form", { onSubmit: handleSubmit, style: getInputContainerStyles(), children: [
|
|
711
|
+
/* @__PURE__ */ jsx(
|
|
712
|
+
"textarea",
|
|
713
|
+
{
|
|
727
714
|
ref: textareaRef,
|
|
728
715
|
value: message,
|
|
729
716
|
onChange: handleInputChange,
|
|
730
717
|
onKeyDown: handleKeyDown,
|
|
731
718
|
placeholder,
|
|
732
719
|
disabled: isLoading,
|
|
733
|
-
style: getTextareaStyles(isLoading)
|
|
734
|
-
}
|
|
735
|
-
|
|
720
|
+
style: getTextareaStyles(isLoading)
|
|
721
|
+
}
|
|
722
|
+
),
|
|
723
|
+
/* @__PURE__ */ jsx(
|
|
724
|
+
"button",
|
|
725
|
+
{
|
|
736
726
|
type: "submit",
|
|
737
727
|
disabled: isLoading || !message.trim(),
|
|
738
728
|
style: getSendButtonStyles(isLoading, !!message.trim()),
|
|
@@ -744,12 +734,10 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
744
734
|
onMouseLeave: (e) => {
|
|
745
735
|
e.currentTarget.style.transform = "scale(1)";
|
|
746
736
|
},
|
|
747
|
-
children: isLoading
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
],
|
|
752
|
-
});
|
|
737
|
+
children: isLoading ? /* @__PURE__ */ jsx(LoadingSpinner, {}) : /* @__PURE__ */ jsx("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" }) })
|
|
738
|
+
}
|
|
739
|
+
)
|
|
740
|
+
] });
|
|
753
741
|
};
|
|
754
742
|
const LoadingSpinner = () => {
|
|
755
743
|
return /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() });
|
|
@@ -757,73 +745,55 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
757
745
|
if (isConfigLoading) {
|
|
758
746
|
return /* @__PURE__ */ jsx("div", { style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, false), children: /* @__PURE__ */ jsx("div", { style: getLoadingSpinnerStyles() }) });
|
|
759
747
|
}
|
|
760
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
messages.length > 0 &&
|
|
810
|
-
/* @__PURE__ */ jsx(MessageBubble, {
|
|
811
|
-
message: {
|
|
812
|
-
id: "typing",
|
|
813
|
-
content: "",
|
|
814
|
-
role: "assistant",
|
|
815
|
-
timestamp: /* @__PURE__ */ new Date(),
|
|
816
|
-
isTyping: true,
|
|
817
|
-
},
|
|
818
|
-
}),
|
|
819
|
-
/* @__PURE__ */ jsx("div", { ref: messagesEndRef }),
|
|
820
|
-
],
|
|
821
|
-
}),
|
|
822
|
-
/* @__PURE__ */ jsx(ChatInput, {}),
|
|
823
|
-
],
|
|
824
|
-
}),
|
|
825
|
-
}),
|
|
826
|
-
/* @__PURE__ */ jsx("button", {
|
|
748
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
749
|
+
isOpen && /* @__PURE__ */ jsx(
|
|
750
|
+
"div",
|
|
751
|
+
{
|
|
752
|
+
style: getOverlayStyles(isOpen),
|
|
753
|
+
onClick: toggleChat,
|
|
754
|
+
className: "floating-chat-overlay"
|
|
755
|
+
}
|
|
756
|
+
),
|
|
757
|
+
/* @__PURE__ */ jsx("div", { style: getChatContainerStyles(buttonPosition, chatWidth, chatHeight, isOpen), className: "floating-chat-container", children: /* @__PURE__ */ jsxs("div", { style: getChatbotContainerStyles(), children: [
|
|
758
|
+
/* @__PURE__ */ jsxs("div", { style: getHeaderStyles(headerBackground), children: [
|
|
759
|
+
/* @__PURE__ */ jsx("div", { style: getLogoContainerStyles(), children: companyLogo ? companyLogo.startsWith("http") || companyLogo.startsWith("data:") ? /* @__PURE__ */ jsx(
|
|
760
|
+
"img",
|
|
761
|
+
{
|
|
762
|
+
src: companyLogo,
|
|
763
|
+
alt: "Company Logo",
|
|
764
|
+
style: getLogoImageStyles()
|
|
765
|
+
}
|
|
766
|
+
) : /* @__PURE__ */ jsx("span", { style: getLogoTextStyles(), children: companyLogo }) : "\u{1F916}" }),
|
|
767
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
768
|
+
/* @__PURE__ */ jsx("h3", { style: getCompanyNameStyles(), children: companyName }),
|
|
769
|
+
/* @__PURE__ */ jsx("p", { style: getStatusTextStyles(), children: isLoading ? "Yaz\u0131yor..." : "\xC7evrimi\xE7i" })
|
|
770
|
+
] })
|
|
771
|
+
] }),
|
|
772
|
+
/* @__PURE__ */ jsxs("div", { style: getMessagesContainerStyles(), children: [
|
|
773
|
+
messages.length === 0 ? /* @__PURE__ */ jsxs("div", { style: getEmptyStateStyles(), children: [
|
|
774
|
+
/* @__PURE__ */ jsx("div", { style: { fontSize: "48px", marginBottom: "16px" }, children: "\u{1F4AC}" }),
|
|
775
|
+
/* @__PURE__ */ jsx("h4", { style: { margin: "0 0 8px 0", fontSize: "18px" }, children: welcomeMessage }),
|
|
776
|
+
/* @__PURE__ */ jsx("p", { style: { margin: 0, fontSize: "14px", opacity: 0.8 }, children: "A\u015Fa\u011F\u0131daki alana mesaj\u0131n\u0131z\u0131 yazarak ba\u015Flayabilirsiniz." })
|
|
777
|
+
] }) : messages.map((message) => /* @__PURE__ */ jsx(MessageBubble, { message }, message.id)),
|
|
778
|
+
showTypingIndicator && isLoading && messages.length > 0 && /* @__PURE__ */ jsx(
|
|
779
|
+
MessageBubble,
|
|
780
|
+
{
|
|
781
|
+
message: {
|
|
782
|
+
id: "typing",
|
|
783
|
+
content: "",
|
|
784
|
+
role: "assistant",
|
|
785
|
+
timestamp: /* @__PURE__ */ new Date(),
|
|
786
|
+
isTyping: true
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
),
|
|
790
|
+
/* @__PURE__ */ jsx("div", { ref: messagesEndRef })
|
|
791
|
+
] }),
|
|
792
|
+
/* @__PURE__ */ jsx(ChatInput, {})
|
|
793
|
+
] }) }),
|
|
794
|
+
/* @__PURE__ */ jsx(
|
|
795
|
+
"button",
|
|
796
|
+
{
|
|
827
797
|
onClick: toggleChat,
|
|
828
798
|
style: getFloatingButtonStyles(buttonPosition, buttonSize, buttonBackground, isOpen),
|
|
829
799
|
onMouseEnter: (e) => {
|
|
@@ -836,26 +806,12 @@ var AizekChatBot = ({ clientId, userToken }) => {
|
|
|
836
806
|
},
|
|
837
807
|
className: "floating-chat-button",
|
|
838
808
|
"aria-label": isOpen ? "Chati kapat" : "Chati a\xE7",
|
|
839
|
-
children: isOpen
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
viewBox: "0 0 24 24",
|
|
844
|
-
fill: "currentColor",
|
|
845
|
-
children: /* @__PURE__ */ jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }),
|
|
846
|
-
})
|
|
847
|
-
: /* @__PURE__ */ jsx("svg", {
|
|
848
|
-
width: "24",
|
|
849
|
-
height: "24",
|
|
850
|
-
viewBox: "0 0 24 24",
|
|
851
|
-
fill: "currentColor",
|
|
852
|
-
children: /* @__PURE__ */ jsx("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" }),
|
|
853
|
-
}),
|
|
854
|
-
}),
|
|
855
|
-
],
|
|
856
|
-
});
|
|
809
|
+
children: isOpen ? /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) : /* @__PURE__ */ jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h4l4 4 4-4h4c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-2 12H6v-2h12v2zm0-3H6V9h12v2zm0-3H6V6h12v2z" }) })
|
|
810
|
+
}
|
|
811
|
+
)
|
|
812
|
+
] });
|
|
857
813
|
};
|
|
858
814
|
|
|
859
815
|
export { AizekChatBot, Button, useChatbot };
|
|
860
816
|
//# sourceMappingURL=index.mjs.map
|
|
861
|
-
//# sourceMappingURL=index.mjs.map
|
|
817
|
+
//# sourceMappingURL=index.mjs.map
|