peppermint-chatbot-sdk 0.1.6 → 0.1.12
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.d.mts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +325 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +327 -100
- package/dist/index.mjs.map +1 -1
- package/dist/logo-transparent-YUL3JUZA.png +0 -0
- package/dist/react/index.d.mts +2 -4
- package/dist/react/index.d.ts +2 -4
- package/dist/react/index.js +325 -98
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +325 -98
- package/dist/react/index.mjs.map +1 -1
- package/dist/vanilla/index.d.mts +32 -4
- package/dist/vanilla/index.d.ts +32 -4
- package/dist/vanilla/index.js +324 -95
- package/dist/vanilla/index.js.map +1 -1
- package/dist/vanilla/index.mjs +326 -97
- package/dist/vanilla/index.mjs.map +1 -1
- package/package.json +1 -4
- package/dist/types-BfQUN3Hf.d.mts +0 -34
- package/dist/types-BfQUN3Hf.d.ts +0 -34
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { PeppermintChatbot
|
|
2
|
-
export { C as ChatMessage, P as PeppermintChatbotProps } from './types-BfQUN3Hf.mjs';
|
|
1
|
+
export { PeppermintChatbot } from './react/index.mjs';
|
|
3
2
|
export { createChatbot } from './vanilla/index.mjs';
|
|
4
3
|
import 'react/jsx-runtime';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export { PeppermintChatbot
|
|
2
|
-
export { C as ChatMessage, P as PeppermintChatbotProps } from './types-BfQUN3Hf.js';
|
|
1
|
+
export { PeppermintChatbot } from './react/index.js';
|
|
3
2
|
export { createChatbot } from './vanilla/index.js';
|
|
4
3
|
import 'react/jsx-runtime';
|
package/dist/index.js
CHANGED
|
@@ -31,170 +31,397 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var src_exports = {};
|
|
32
32
|
__export(src_exports, {
|
|
33
33
|
PeppermintChatbot: () => PeppermintChatbot,
|
|
34
|
-
createChatbot: () => createChatbot
|
|
35
|
-
default: () => Chatbot_default
|
|
34
|
+
createChatbot: () => createChatbot
|
|
36
35
|
});
|
|
37
36
|
module.exports = __toCommonJS(src_exports);
|
|
38
37
|
|
|
39
|
-
// src/react/
|
|
38
|
+
// src/react/PeppermintChatbot/index.tsx
|
|
40
39
|
var import_react = require("react");
|
|
40
|
+
|
|
41
|
+
// src/react/PeppermintChatbot/index.styles.ts
|
|
41
42
|
var import_styled_components = __toESM(require("styled-components"));
|
|
42
|
-
var
|
|
43
|
-
|
|
43
|
+
var Container = import_styled_components.default.div`
|
|
44
|
+
position: fixed;
|
|
45
|
+
bottom: 32px;
|
|
46
|
+
right: 32px;
|
|
47
|
+
width: fit-content;
|
|
48
|
+
height: fit-content;
|
|
44
49
|
display: flex;
|
|
45
50
|
flex-direction: column;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
`;
|
|
52
|
+
var WidgetButton = import_styled_components.default.button`
|
|
53
|
+
width: 60px;
|
|
54
|
+
height: 60px;
|
|
55
|
+
border: none;
|
|
56
|
+
border-radius: 50%;
|
|
57
|
+
cursor: pointer;
|
|
58
|
+
padding: 0;
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
justify-content: center;
|
|
62
|
+
color: #ffffff;
|
|
63
|
+
background: #1a1a1a;
|
|
64
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
|
|
65
|
+
|
|
66
|
+
transition: all 0.2s ease-in-out;
|
|
67
|
+
|
|
68
|
+
&:hover {
|
|
69
|
+
transform: scale(1.05);
|
|
70
|
+
}
|
|
71
|
+
`;
|
|
72
|
+
var ChatbotContainer = import_styled_components.default.div`
|
|
73
|
+
position: absolute;
|
|
74
|
+
bottom: calc(100% + 16px);
|
|
75
|
+
right: 0;
|
|
76
|
+
box-sizing: border-box;
|
|
77
|
+
background: #ffffff;
|
|
78
|
+
width: 450px;
|
|
79
|
+
height: 500px;
|
|
80
|
+
min-height: 320px;
|
|
81
|
+
max-height: 520px;
|
|
82
|
+
border-radius: 20px 20px 24px 24px;
|
|
83
|
+
border: 1px solid #e0e0e0;
|
|
84
|
+
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
|
|
53
85
|
overflow: hidden;
|
|
86
|
+
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
|
|
54
90
|
font-family: system-ui, -apple-system, sans-serif;
|
|
55
91
|
font-size: 14px;
|
|
56
|
-
|
|
92
|
+
color: #1a1a1a;
|
|
93
|
+
|
|
94
|
+
opacity: ${(p) => p.$visible ? 1 : 0};
|
|
95
|
+
filter: ${(p) => p.$visible ? "blur(0)" : "blur(8px)"};
|
|
96
|
+
transition: opacity 0.3s ease-out, filter 0.3s ease-out;
|
|
97
|
+
pointer-events: ${(p) => p.$visible ? "auto" : "none"};
|
|
98
|
+
`;
|
|
99
|
+
var Header = import_styled_components.default.div`
|
|
100
|
+
position: relative;
|
|
101
|
+
height: 44px;
|
|
102
|
+
display: flex;
|
|
103
|
+
justify-content: space-between;
|
|
104
|
+
align-items: center;
|
|
105
|
+
padding: 0 8px 0 16px;
|
|
106
|
+
`;
|
|
107
|
+
var HeaderMarginBottom = import_styled_components.default.div`
|
|
108
|
+
position: absolute;
|
|
109
|
+
top: 100%;
|
|
110
|
+
left: 0;
|
|
111
|
+
right: 0;
|
|
112
|
+
height: 8px;
|
|
113
|
+
background: linear-gradient(to top, transparent, #ffffff);
|
|
57
114
|
`;
|
|
58
|
-
var
|
|
115
|
+
var ChatbotName = import_styled_components.default.div`
|
|
116
|
+
font-size: 14px;
|
|
117
|
+
color: #1a1a1a;
|
|
118
|
+
`;
|
|
119
|
+
var IconButton = import_styled_components.default.button`
|
|
120
|
+
width: 32px;
|
|
121
|
+
height: 32px;
|
|
122
|
+
padding: 0;
|
|
123
|
+
display: flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
color: #1a1a1a;
|
|
127
|
+
background: transparent;
|
|
128
|
+
border: none;
|
|
129
|
+
border-radius: 8px;
|
|
130
|
+
cursor: pointer;
|
|
131
|
+
|
|
132
|
+
&:hover {
|
|
133
|
+
background: rgba(0, 0, 0, 0.06);
|
|
134
|
+
}
|
|
135
|
+
`;
|
|
136
|
+
var MessageList = import_styled_components.default.div`
|
|
59
137
|
flex: 1;
|
|
60
138
|
overflow-y: auto;
|
|
61
|
-
|
|
139
|
+
overflow-x: hidden;
|
|
140
|
+
|
|
62
141
|
display: flex;
|
|
63
142
|
flex-direction: column;
|
|
64
143
|
gap: 0.75rem;
|
|
144
|
+
padding: 16px;
|
|
145
|
+
|
|
146
|
+
/* Firefox */
|
|
147
|
+
scrollbar-width: thin;
|
|
148
|
+
scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
|
|
149
|
+
|
|
150
|
+
/* WebKit (Chrome, Safari, Edge) */
|
|
151
|
+
&::-webkit-scrollbar {
|
|
152
|
+
width: 8px;
|
|
153
|
+
}
|
|
154
|
+
&::-webkit-scrollbar-track {
|
|
155
|
+
background: transparent;
|
|
156
|
+
}
|
|
157
|
+
&::-webkit-scrollbar-thumb {
|
|
158
|
+
background: rgba(0, 0, 0, 0.25);
|
|
159
|
+
border-radius: 4px;
|
|
160
|
+
}
|
|
161
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
162
|
+
background: rgba(0, 0, 0, 0.35);
|
|
163
|
+
}
|
|
65
164
|
`;
|
|
66
165
|
var MessageBubble = import_styled_components.default.div`
|
|
67
|
-
align-self: ${(p) => p.$role === "user" ? "flex-end" : "flex-start"};
|
|
68
166
|
max-width: 85%;
|
|
69
|
-
padding: 0.6rem 1rem;
|
|
70
167
|
border-radius: 12px;
|
|
71
|
-
|
|
168
|
+
|
|
169
|
+
padding: 0.6rem 1rem;
|
|
170
|
+
|
|
72
171
|
word-break: break-word;
|
|
73
|
-
|
|
172
|
+
line-height: 1.45;
|
|
173
|
+
|
|
174
|
+
align-self: ${(p) => p.$role === "user" ? "flex-end" : "flex-start"};
|
|
175
|
+
background: ${(p) => p.$role === "user" ? "#2d2d2d" : "#f0f0f0"};
|
|
74
176
|
color: ${(p) => p.$role === "user" ? "#ffffff" : "#1a1a1a"};
|
|
75
177
|
`;
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
opacity: 0.85;
|
|
178
|
+
var Footer = import_styled_components.default.div`
|
|
179
|
+
background-color: transparent;
|
|
180
|
+
position: relative;
|
|
80
181
|
`;
|
|
81
|
-
var
|
|
182
|
+
var InputContainerMarginTop = import_styled_components.default.div`
|
|
183
|
+
position: absolute;
|
|
184
|
+
top: -8px;
|
|
185
|
+
left: 0;
|
|
186
|
+
right: 0;
|
|
187
|
+
height: 8px;
|
|
188
|
+
background: linear-gradient(to bottom, transparent, #ffffff);
|
|
189
|
+
`;
|
|
190
|
+
var InputContainer = import_styled_components.default.div`
|
|
191
|
+
position: relative;
|
|
192
|
+
height: 90px;
|
|
82
193
|
display: flex;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
border-
|
|
86
|
-
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
justify-content: flex-end;
|
|
196
|
+
border-radius: 16px;
|
|
197
|
+
border: 1px solid #e0e0e0;
|
|
198
|
+
background: #ffffff;
|
|
199
|
+
margin: 8px 16px 0px 16px;
|
|
200
|
+
|
|
201
|
+
&:focus-within {
|
|
202
|
+
border-color: rgba(0, 0, 0, 0.3);
|
|
203
|
+
}
|
|
87
204
|
`;
|
|
88
|
-
var
|
|
205
|
+
var Textarea = import_styled_components.default.textarea`
|
|
89
206
|
flex: 1;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
border
|
|
207
|
+
background-color: transparent;
|
|
208
|
+
margin: 8px 8px 8px 16px;
|
|
209
|
+
border: none;
|
|
93
210
|
font-size: 14px;
|
|
94
211
|
outline: none;
|
|
212
|
+
resize: none;
|
|
213
|
+
min-height: 24px;
|
|
214
|
+
max-height: 120px;
|
|
215
|
+
line-height: 1.4;
|
|
216
|
+
font-family: inherit;
|
|
217
|
+
|
|
95
218
|
&::placeholder {
|
|
96
219
|
color: #888;
|
|
97
220
|
}
|
|
98
|
-
|
|
99
|
-
|
|
221
|
+
|
|
222
|
+
/* Firefox */
|
|
223
|
+
scrollbar-width: thin;
|
|
224
|
+
scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
|
|
225
|
+
|
|
226
|
+
/* WebKit (Chrome, Safari, Edge) */
|
|
227
|
+
&::-webkit-scrollbar {
|
|
228
|
+
width: 8px;
|
|
229
|
+
}
|
|
230
|
+
&::-webkit-scrollbar-track {
|
|
231
|
+
background: transparent;
|
|
232
|
+
}
|
|
233
|
+
&::-webkit-scrollbar-thumb {
|
|
234
|
+
background: rgba(0, 0, 0, 0.25);
|
|
235
|
+
border-radius: 4px;
|
|
236
|
+
}
|
|
237
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
238
|
+
background: rgba(0, 0, 0, 0.35);
|
|
100
239
|
}
|
|
101
240
|
`;
|
|
241
|
+
var InputContainerFooter = import_styled_components.default.div`
|
|
242
|
+
position: absolute;
|
|
243
|
+
bottom: 0;
|
|
244
|
+
right: 0;
|
|
245
|
+
height: 36px;
|
|
246
|
+
display: flex;
|
|
247
|
+
justify-content: flex-end;
|
|
248
|
+
align-items: center;
|
|
249
|
+
padding-left: 4px;
|
|
250
|
+
padding-right: 4px;
|
|
251
|
+
background-color: transparent;
|
|
252
|
+
`;
|
|
102
253
|
var SendButton = import_styled_components.default.button`
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
254
|
+
width: 28px;
|
|
255
|
+
height: 28px;
|
|
256
|
+
padding: 0;
|
|
257
|
+
display: flex;
|
|
258
|
+
align-items: center;
|
|
259
|
+
justify-content: center;
|
|
106
260
|
color: #fff;
|
|
107
261
|
background: #1a1a1a;
|
|
108
262
|
border: none;
|
|
109
|
-
border-radius:
|
|
263
|
+
border-radius: 50%;
|
|
110
264
|
cursor: pointer;
|
|
111
|
-
|
|
265
|
+
|
|
266
|
+
&:hover:not(:disabled) {
|
|
112
267
|
opacity: 0.9;
|
|
113
268
|
}
|
|
269
|
+
|
|
114
270
|
&:disabled {
|
|
115
271
|
opacity: 0.5;
|
|
116
272
|
cursor: not-allowed;
|
|
117
273
|
}
|
|
118
274
|
`;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
275
|
+
var PoweredBy = import_styled_components.default.a`
|
|
276
|
+
display: block;
|
|
277
|
+
font-size: 8px;
|
|
278
|
+
color: #888;
|
|
279
|
+
text-decoration: none;
|
|
280
|
+
padding: 4px 16px 4px 16px;
|
|
281
|
+
text-align: center;
|
|
282
|
+
cursor: pointer;
|
|
283
|
+
|
|
284
|
+
&:hover {
|
|
285
|
+
color: #1a1a1a;
|
|
286
|
+
}
|
|
287
|
+
`;
|
|
288
|
+
|
|
289
|
+
// src/assets/logo-transparent.png
|
|
290
|
+
var logo_transparent_default = "./logo-transparent-YUL3JUZA.png";
|
|
291
|
+
|
|
292
|
+
// src/react/PeppermintChatbot/index.tsx
|
|
293
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
294
|
+
var BLUR_FADE_MS = 200;
|
|
295
|
+
function PeppermintChatbot() {
|
|
296
|
+
const [isOpen, setIsOpen] = (0, import_react.useState)(false);
|
|
297
|
+
const [isVisible, setIsVisible] = (0, import_react.useState)(false);
|
|
298
|
+
const [isTransitioningOpen, setIsTransitioningOpen] = (0, import_react.useState)(false);
|
|
132
299
|
const [input, setInput] = (0, import_react.useState)("");
|
|
300
|
+
const [messageList, setMessageList] = (0, import_react.useState)([]);
|
|
133
301
|
const messagesEndRef = (0, import_react.useRef)(null);
|
|
302
|
+
(0, import_react.useEffect)(() => {
|
|
303
|
+
if (isOpen) {
|
|
304
|
+
setIsVisible(true);
|
|
305
|
+
let cancelled = false;
|
|
306
|
+
const id = requestAnimationFrame(() => {
|
|
307
|
+
requestAnimationFrame(() => {
|
|
308
|
+
if (!cancelled) setIsTransitioningOpen(true);
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
return () => {
|
|
312
|
+
cancelled = true;
|
|
313
|
+
cancelAnimationFrame(id);
|
|
314
|
+
};
|
|
315
|
+
} else {
|
|
316
|
+
setIsTransitioningOpen(false);
|
|
317
|
+
const id = window.setTimeout(() => setIsVisible(false), BLUR_FADE_MS);
|
|
318
|
+
return () => clearTimeout(id);
|
|
319
|
+
}
|
|
320
|
+
}, [isOpen]);
|
|
134
321
|
(0, import_react.useEffect)(() => {
|
|
135
322
|
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
136
|
-
}, [
|
|
323
|
+
}, [messageList]);
|
|
137
324
|
const handleSend = () => {
|
|
138
325
|
const text = input.trim();
|
|
139
326
|
if (!text) return;
|
|
140
|
-
const
|
|
327
|
+
const userMessage = {
|
|
141
328
|
id: `u-${Date.now()}`,
|
|
142
329
|
role: "user",
|
|
143
|
-
content: text
|
|
330
|
+
content: text,
|
|
331
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
144
332
|
};
|
|
145
|
-
|
|
333
|
+
setMessageList((prev) => [...prev, userMessage]);
|
|
146
334
|
setInput("");
|
|
147
|
-
onSendMessage?.(text);
|
|
148
335
|
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
)),
|
|
178
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: messagesEndRef })
|
|
179
|
-
] }),
|
|
180
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(InputRow, { children: [
|
|
336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Container, { children: [
|
|
337
|
+
isVisible && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(ChatbotContainer, { $visible: isOpen && isTransitioningOpen, children: [
|
|
338
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Header, { children: [
|
|
339
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatbotName, { children: "Peppermint Chatbot" }),
|
|
340
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButton, { type: "button", "aria-label": "Minimize", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
341
|
+
"svg",
|
|
342
|
+
{
|
|
343
|
+
width: "20",
|
|
344
|
+
height: "20",
|
|
345
|
+
viewBox: "0 0 24 24",
|
|
346
|
+
fill: "none",
|
|
347
|
+
stroke: "currentColor",
|
|
348
|
+
strokeWidth: "2",
|
|
349
|
+
strokeLinecap: "round",
|
|
350
|
+
strokeLinejoin: "round",
|
|
351
|
+
"aria-hidden": true,
|
|
352
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 12h14" })
|
|
353
|
+
}
|
|
354
|
+
) }),
|
|
355
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(HeaderMarginBottom, {})
|
|
356
|
+
] }),
|
|
357
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(MessageList, { children: [
|
|
358
|
+
messageList.map((msg) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MessageBubble, { $role: msg.role, children: msg.content }, msg.id)),
|
|
359
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref: messagesEndRef })
|
|
360
|
+
] }),
|
|
361
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Footer, { children: [
|
|
362
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(InputContainerMarginTop, {}),
|
|
363
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(InputContainer, { children: [
|
|
181
364
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
182
|
-
|
|
365
|
+
Textarea,
|
|
183
366
|
{
|
|
184
|
-
type: "text",
|
|
185
367
|
placeholder: "Type a message...",
|
|
186
368
|
value: input,
|
|
187
369
|
onChange: (e) => setInput(e.target.value),
|
|
188
|
-
onKeyDown: (e) =>
|
|
370
|
+
onKeyDown: (e) => {
|
|
371
|
+
if (e.key === "Enter" && !e.nativeEvent.isComposing) {
|
|
372
|
+
if (!e.shiftKey) {
|
|
373
|
+
e.preventDefault();
|
|
374
|
+
handleSend();
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
rows: 1,
|
|
379
|
+
"aria-label": "Message"
|
|
189
380
|
}
|
|
190
381
|
),
|
|
191
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
382
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(InputContainerFooter, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
383
|
+
SendButton,
|
|
384
|
+
{
|
|
385
|
+
type: "button",
|
|
386
|
+
onClick: handleSend,
|
|
387
|
+
disabled: !input.trim(),
|
|
388
|
+
"aria-label": "Send",
|
|
389
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
390
|
+
"svg",
|
|
391
|
+
{
|
|
392
|
+
width: "16",
|
|
393
|
+
height: "16",
|
|
394
|
+
viewBox: "0 0 24 24",
|
|
395
|
+
fill: "none",
|
|
396
|
+
stroke: "currentColor",
|
|
397
|
+
strokeWidth: "2.5",
|
|
398
|
+
strokeLinecap: "round",
|
|
399
|
+
strokeLinejoin: "round",
|
|
400
|
+
"aria-hidden": true,
|
|
401
|
+
children: [
|
|
402
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 19V5" }),
|
|
403
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 12l7-7 7 7" })
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
) })
|
|
409
|
+
] }),
|
|
410
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(PoweredBy, { href: "", target: "_blank", rel: "noopener noreferrer", children: "Powered by Peppermint Chatbot" })
|
|
411
|
+
] })
|
|
412
|
+
] }),
|
|
413
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(WidgetButton, { onClick: () => setIsOpen((prev) => !prev), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
414
|
+
"img",
|
|
415
|
+
{
|
|
416
|
+
src: logo_transparent_default,
|
|
417
|
+
alt: "Peppermint Chatbot",
|
|
418
|
+
width: 60,
|
|
419
|
+
height: 60,
|
|
420
|
+
draggable: false
|
|
421
|
+
}
|
|
422
|
+
) })
|
|
423
|
+
] });
|
|
196
424
|
}
|
|
197
|
-
var Chatbot_default = PeppermintChatbot;
|
|
198
425
|
|
|
199
426
|
// src/vanilla/index.ts
|
|
200
427
|
var import_react2 = __toESM(require("react"));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/react/Chatbot.tsx","../src/vanilla/index.ts"],"sourcesContent":["export { PeppermintChatbot, default } from \"./react\";\nexport { createChatbot } from \"./vanilla\";\nexport type { PeppermintChatbotProps, ChatMessage } from \"./types\";\n","import React, { useState, useRef, useEffect } from \"react\";\nimport styled from \"styled-components\";\nimport type { PeppermintChatbotProps, ChatMessage } from \"../types\";\n\nconst Root = styled.div<{\n $backgroundColor?: string;\n $fontColor?: string;\n $layout: \"widget\" | \"page\";\n}>`\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 100%;\n min-height: ${(p) => (p.$layout === \"page\" ? \"400px\" : \"320px\")};\n max-height: ${(p) => (p.$layout === \"page\" ? \"620px\" : \"520px\")};\n background: ${(p) => p.$backgroundColor ?? \"#ffffff\"};\n color: ${(p) => p.$fontColor ?? \"#1a1a1a\"};\n border-radius: 16px;\n overflow: hidden;\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 14px;\n box-sizing: border-box;\n`;\n\nconst Messages = styled.div`\n flex: 1;\n overflow-y: auto;\n padding: 1rem;\n display: flex;\n flex-direction: column;\n gap: 0.75rem;\n`;\n\nconst MessageBubble = styled.div<{\n $role: \"user\" | \"assistant\";\n $userBubbleColor?: string;\n $chatbotBubbleColor?: string;\n}>`\n align-self: ${(p) => (p.$role === \"user\" ? \"flex-end\" : \"flex-start\")};\n max-width: 85%;\n padding: 0.6rem 1rem;\n border-radius: 12px;\n line-height: 1.45;\n word-break: break-word;\n background: ${(p) =>\n p.$role === \"user\"\n ? p.$userBubbleColor ?? \"#2d2d2d\"\n : p.$chatbotBubbleColor ?? \"#f0f0f0\"};\n color: ${(p) => (p.$role === \"user\" ? \"#ffffff\" : \"#1a1a1a\")};\n`;\n\nconst Greeting = styled.p`\n margin: 0;\n color: inherit;\n opacity: 0.85;\n`;\n\nconst InputRow = styled.div`\n display: flex;\n gap: 0.5rem;\n padding: 0.75rem 1rem;\n border-top: 1px solid rgba(0, 0, 0, 0.08);\n background: rgba(0, 0, 0, 0.02);\n`;\n\nconst Input = styled.input`\n flex: 1;\n padding: 0.6rem 0.75rem;\n border: 1px solid rgba(0, 0, 0, 0.12);\n border-radius: 8px;\n font-size: 14px;\n outline: none;\n &::placeholder {\n color: #888;\n }\n &:focus {\n border-color: rgba(0, 0, 0, 0.3);\n }\n`;\n\nconst SendButton = styled.button`\n padding: 0.6rem 1rem;\n font-size: 14px;\n font-weight: 600;\n color: #fff;\n background: #1a1a1a;\n border: none;\n border-radius: 8px;\n cursor: pointer;\n &:hover {\n opacity: 0.9;\n }\n &:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n`;\n\nexport function PeppermintChatbot({\n layout = \"page\",\n chatbotName,\n greetingMessage = \"Hi! How can I help you today?\",\n backgroundColor,\n fontColor,\n chatbotBubbleColor,\n userBubbleColor,\n initialMessages = [],\n onSendMessage,\n className,\n}: PeppermintChatbotProps) {\n const [messages, setMessages] = useState<ChatMessage[]>(initialMessages);\n const [input, setInput] = useState(\"\");\n const messagesEndRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n messagesEndRef.current?.scrollIntoView({ behavior: \"smooth\" });\n }, [messages]);\n\n const handleSend = () => {\n const text = input.trim();\n if (!text) return;\n const userMsg: ChatMessage = {\n id: `u-${Date.now()}`,\n role: \"user\",\n content: text,\n };\n setMessages((prev) => [...prev, userMsg]);\n setInput(\"\");\n onSendMessage?.(text);\n };\n\n const showGreeting = messages.length === 0 && greetingMessage;\n\n return (\n <Root\n className={className}\n $layout={layout}\n $backgroundColor={backgroundColor}\n $fontColor={fontColor}\n >\n <Messages>\n {showGreeting && (\n <MessageBubble\n $role=\"assistant\"\n $chatbotBubbleColor={chatbotBubbleColor}\n $userBubbleColor={userBubbleColor}\n >\n <Greeting>{greetingMessage}</Greeting>\n </MessageBubble>\n )}\n {messages.map((msg) => (\n <MessageBubble\n key={msg.id}\n $role={msg.role}\n $chatbotBubbleColor={chatbotBubbleColor}\n $userBubbleColor={userBubbleColor}\n >\n {msg.content}\n </MessageBubble>\n ))}\n <div ref={messagesEndRef} />\n </Messages>\n <InputRow>\n <Input\n type=\"text\"\n placeholder=\"Type a message...\"\n value={input}\n onChange={(e) => setInput(e.target.value)}\n onKeyDown={(e) => e.key === \"Enter\" && handleSend()}\n />\n <SendButton type=\"button\" onClick={handleSend} disabled={!input.trim()}>\n Send\n </SendButton>\n </InputRow>\n </Root>\n );\n}\n\nexport default PeppermintChatbot;\n","import React from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { PeppermintChatbot } from \"../react\";\nimport type { PeppermintChatbotProps } from \"../types\";\n\n/**\n * Mount the chatbot into a container (vanilla JS, Vue, Svelte).\n * Requires react and react-dom to be available (e.g. via script or bundler).\n */\nexport function createChatbot(\n container: HTMLElement,\n props: PeppermintChatbotProps = {}\n): { unmount: () => void } {\n const root = createRoot(container);\n root.render(React.createElement(PeppermintChatbot, props));\n return {\n unmount: () => root.unmount(),\n };\n}\n\nexport type { PeppermintChatbotProps } from \"../types\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAAmD;AACnD,+BAAmB;AA2Ib;AAxIN,IAAM,OAAO,yBAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA,gBASJ,CAAC,MAAO,EAAE,YAAY,SAAS,UAAU,OAAQ;AAAA,gBACjD,CAAC,MAAO,EAAE,YAAY,SAAS,UAAU,OAAQ;AAAA,gBACjD,CAAC,MAAM,EAAE,oBAAoB,SAAS;AAAA,WAC3C,CAAC,MAAM,EAAE,cAAc,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ3C,IAAM,WAAW,yBAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASxB,IAAM,gBAAgB,yBAAAA,QAAO;AAAA,gBAKb,CAAC,MAAO,EAAE,UAAU,SAAS,aAAa,YAAa;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAMvD,CAAC,MACb,EAAE,UAAU,SACR,EAAE,oBAAoB,YACtB,EAAE,uBAAuB,SAAS;AAAA,WAC/B,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AkB;AAAA,MAClB,YAAY;AAAA,MAEZ;AAAA,qDAAC,YACE;AAAA,0BACC;AAAA,YAAC;AAAA;AAAA,cACC,OAAM;AAAA,cACN,qBAAqB;AAAA,cACrB,kBAAkB;AAAA,cAElB,sDAAC,YAAU,2BAAgB;AAAA;AAAA,UAC7B;AAAA,UAED,SAAS,IAAI,CAAC,QACb;AAAA,YAAC;AAAA;AAAA,cAEC,OAAO,IAAI;AAAA,cACX,qBAAqB;AAAA,cACrB,kBAAkB;AAAA,cAEjB,cAAI;AAAA;AAAA,YALA,IAAI;AAAA,UAMX,CACD;AAAA,UACD,4CAAC,SAAI,KAAK,gBAAgB;AAAA,WAC5B;AAAA,QACA,6CAAC,YACC;AAAA;AAAA,YAAC;AAAA;AAAA,cACC,MAAK;AAAA,cACL,aAAY;AAAA,cACZ,OAAO;AAAA,cACP,UAAU,CAAC,MAAM,SAAS,EAAE,OAAO,KAAK;AAAA,cACxC,WAAW,CAAC,MAAM,EAAE,QAAQ,WAAW,WAAW;AAAA;AAAA,UACpD;AAAA,UACA,4CAAC,cAAW,MAAK,UAAS,SAAS,YAAY,UAAU,CAAC,MAAM,KAAK,GAAG,kBAExE;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;AAEA,IAAO,kBAAQ;;;AClLf,IAAAC,gBAAkB;AAClB,oBAA2B;AAQpB,SAAS,cACd,WACA,QAAgC,CAAC,GACR;AACzB,QAAM,WAAO,0BAAW,SAAS;AACjC,OAAK,OAAO,cAAAC,QAAM,cAAc,mBAAmB,KAAK,CAAC;AACzD,SAAO;AAAA,IACL,SAAS,MAAM,KAAK,QAAQ;AAAA,EAC9B;AACF;","names":["styled","import_react","React"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/react/PeppermintChatbot/index.tsx","../src/react/PeppermintChatbot/index.styles.ts","../src/vanilla/index.ts"],"sourcesContent":["export { PeppermintChatbot } from \"./react\";\nexport { createChatbot } from \"./vanilla\";\n","import { useState, useRef, useEffect } from \"react\";\nimport {\n ChatbotContainer,\n MessageList,\n MessageBubble,\n InputContainer,\n Textarea,\n SendButton,\n Header,\n ChatbotName,\n IconButton,\n PoweredBy,\n Footer,\n InputContainerFooter,\n InputContainerMarginTop,\n HeaderMarginBottom,\n WidgetButton,\n Container,\n} from \"./index.styles\";\nimport type { Message } from \"./index.types\";\nimport LogoTransparent from \"../../assets/logo-transparent.png\";\n\nconst BLUR_FADE_MS = 200;\n\nfunction PeppermintChatbot() {\n const [isOpen, setIsOpen] = useState(false);\n const [isVisible, setIsVisible] = useState(false);\n const [isTransitioningOpen, setIsTransitioningOpen] = useState(false);\n const [input, setInput] = useState(\"\");\n const [messageList, setMessageList] = useState<Message[]>([]);\n\n const messagesEndRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (isOpen) {\n setIsVisible(true);\n let cancelled = false;\n const id = requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n if (!cancelled) setIsTransitioningOpen(true);\n });\n });\n return () => {\n cancelled = true;\n cancelAnimationFrame(id);\n };\n } else {\n setIsTransitioningOpen(false);\n const id = window.setTimeout(() => setIsVisible(false), BLUR_FADE_MS);\n return () => clearTimeout(id);\n }\n }, [isOpen]);\n\n useEffect(() => {\n messagesEndRef.current?.scrollIntoView({ behavior: \"smooth\" });\n }, [messageList]);\n\n const handleSend = () => {\n const text = input.trim();\n\n if (!text) return;\n\n const userMessage: Message = {\n id: `u-${Date.now()}`,\n role: \"user\",\n content: text,\n timestamp: new Date().toISOString(),\n };\n\n setMessageList((prev) => [...prev, userMessage]);\n setInput(\"\");\n };\n\n return (\n <Container>\n {isVisible && (\n <ChatbotContainer $visible={isOpen && isTransitioningOpen}>\n <Header>\n <ChatbotName>Peppermint Chatbot</ChatbotName>\n <IconButton type=\"button\" aria-label=\"Minimize\">\n <svg\n width=\"20\"\n height=\"20\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden\n >\n <path d=\"M5 12h14\" />\n </svg>\n </IconButton>\n <HeaderMarginBottom />\n </Header>\n\n <MessageList>\n {messageList.map((msg) => (\n <MessageBubble key={msg.id} $role={msg.role}>\n {msg.content}\n </MessageBubble>\n ))}\n\n <div ref={messagesEndRef} />\n </MessageList>\n\n <Footer>\n <InputContainerMarginTop />\n <InputContainer>\n <Textarea\n placeholder=\"Type a message...\"\n value={input}\n onChange={(e) => setInput(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\" && !e.nativeEvent.isComposing) {\n if (!e.shiftKey) {\n e.preventDefault();\n handleSend();\n }\n }\n }}\n rows={1}\n aria-label=\"Message\"\n />\n\n <InputContainerFooter>\n <SendButton\n type=\"button\"\n onClick={handleSend}\n disabled={!input.trim()}\n aria-label=\"Send\"\n >\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2.5\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden\n >\n <path d=\"M12 19V5\" />\n <path d=\"M5 12l7-7 7 7\" />\n </svg>\n </SendButton>\n </InputContainerFooter>\n </InputContainer>\n\n <PoweredBy href=\"\" target=\"_blank\" rel=\"noopener noreferrer\">\n Powered by Peppermint Chatbot\n </PoweredBy>\n </Footer>\n </ChatbotContainer>\n )}\n\n <WidgetButton onClick={() => setIsOpen((prev) => !prev)}>\n <img\n src={LogoTransparent}\n alt=\"Peppermint Chatbot\"\n width={60}\n height={60}\n draggable={false}\n />\n </WidgetButton>\n </Container>\n );\n}\n\nexport { PeppermintChatbot };\n","import styled from \"styled-components\";\nimport type { ComponentType } from \"react\";\nimport type { Role } from \"./index.types\";\n\nconst Container: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n position: fixed;\n bottom: 32px;\n right: 32px;\n width: fit-content;\n height: fit-content;\n display: flex;\n flex-direction: column;\n`;\n\nconst WidgetButton: ComponentType<React.HTMLAttributes<HTMLButtonElement>> = styled.button`\n width: 60px;\n height: 60px;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #ffffff;\n background: #1a1a1a;\n box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);\n\n transition: all 0.2s ease-in-out;\n\n &:hover {\n transform: scale(1.05);\n }\n`;\n\nconst ChatbotContainer: ComponentType<\n React.HTMLAttributes<HTMLDivElement> & { $visible?: boolean }\n> = styled.div<{ $visible?: boolean }>`\n position: absolute;\n bottom: calc(100% + 16px);\n right: 0;\n box-sizing: border-box;\n background: #ffffff;\n width: 450px;\n height: 500px;\n min-height: 320px;\n max-height: 520px;\n border-radius: 20px 20px 24px 24px;\n border: 1px solid #e0e0e0;\n box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);\n overflow: hidden;\n\n display: flex;\n flex-direction: column;\n\n font-family: system-ui, -apple-system, sans-serif;\n font-size: 14px;\n color: #1a1a1a;\n\n opacity: ${(p) => (p.$visible ? 1 : 0)};\n filter: ${(p) => (p.$visible ? \"blur(0)\" : \"blur(8px)\")};\n transition: opacity 0.3s ease-out, filter 0.3s ease-out;\n pointer-events: ${(p) => (p.$visible ? \"auto\" : \"none\")};\n`;\n\nconst Header: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n position: relative;\n height: 44px;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 0 8px 0 16px;\n`;\n\nconst HeaderMarginBottom: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n position: absolute;\n top: 100%;\n left: 0;\n right: 0;\n height: 8px;\n background: linear-gradient(to top, transparent, #ffffff);\n`;\n\nconst ChatbotName: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n font-size: 14px;\n color: #1a1a1a;\n`;\n\nconst IconButton: ComponentType<\n React.ButtonHTMLAttributes<HTMLButtonElement>\n> = styled.button`\n width: 32px;\n height: 32px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #1a1a1a;\n background: transparent;\n border: none;\n border-radius: 8px;\n cursor: pointer;\n\n &:hover {\n background: rgba(0, 0, 0, 0.06);\n }\n`;\n\nconst MessageList: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n flex: 1;\n overflow-y: auto;\n overflow-x: hidden;\n\n display: flex;\n flex-direction: column;\n gap: 0.75rem;\n padding: 16px;\n\n /* Firefox */\n scrollbar-width: thin;\n scrollbar-color: rgba(0, 0, 0, 0.25) transparent;\n\n /* WebKit (Chrome, Safari, Edge) */\n &::-webkit-scrollbar {\n width: 8px;\n }\n &::-webkit-scrollbar-track {\n background: transparent;\n }\n &::-webkit-scrollbar-thumb {\n background: rgba(0, 0, 0, 0.25);\n border-radius: 4px;\n }\n &::-webkit-scrollbar-thumb:hover {\n background: rgba(0, 0, 0, 0.35);\n }\n`;\n\nconst MessageBubble: ComponentType<React.HTMLAttributes<HTMLDivElement> & { $role: Role }> = styled.div`\n max-width: 85%;\n border-radius: 12px;\n\n padding: 0.6rem 1rem;\n \n word-break: break-word;\n line-height: 1.45;\n\n align-self: ${(p) => (p.$role === \"user\" ? \"flex-end\" : \"flex-start\")};\n background: ${(p) => (p.$role === \"user\" ? \"#2d2d2d\" : \"#f0f0f0\")};\n color: ${(p) => (p.$role === \"user\" ? \"#ffffff\" : \"#1a1a1a\")};\n`;\n\nconst Footer: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n background-color: transparent;\n position: relative;\n`;\n\nconst InputContainerMarginTop: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n position: absolute;\n top: -8px;\n left: 0;\n right: 0;\n height: 8px;\n background: linear-gradient(to bottom, transparent, #ffffff);\n`;\n\nconst InputContainer: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n position: relative;\n height: 90px;\n display: flex;\n flex-direction: column;\n justify-content: flex-end;\n border-radius: 16px;\n border: 1px solid #e0e0e0;\n background: #ffffff;\n margin: 8px 16px 0px 16px;\n \n &:focus-within {\n border-color: rgba(0, 0, 0, 0.3);\n }\n`;\n\nconst Textarea: ComponentType<\n React.TextareaHTMLAttributes<HTMLTextAreaElement>\n> = styled.textarea`\n flex: 1;\n background-color: transparent;\n margin: 8px 8px 8px 16px;\n border: none;\n font-size: 14px;\n outline: none;\n resize: none;\n min-height: 24px;\n max-height: 120px;\n line-height: 1.4;\n font-family: inherit;\n\n &::placeholder {\n color: #888;\n }\n\n /* Firefox */\n scrollbar-width: thin;\n scrollbar-color: rgba(0, 0, 0, 0.25) transparent;\n\n /* WebKit (Chrome, Safari, Edge) */\n &::-webkit-scrollbar {\n width: 8px;\n }\n &::-webkit-scrollbar-track {\n background: transparent;\n }\n &::-webkit-scrollbar-thumb {\n background: rgba(0, 0, 0, 0.25);\n border-radius: 4px;\n }\n &::-webkit-scrollbar-thumb:hover {\n background: rgba(0, 0, 0, 0.35);\n }\n`;\n\nconst InputContainerFooter: ComponentType<React.HTMLAttributes<HTMLDivElement>> = styled.div`\n position: absolute;\n bottom: 0;\n right: 0;\n height: 36px;\n display: flex;\n justify-content: flex-end;\n align-items: center;\n padding-left: 4px;\n padding-right: 4px;\n background-color: transparent;\n`;\n\nconst SendButton: ComponentType<\n React.ButtonHTMLAttributes<HTMLButtonElement>\n> = styled.button`\n width: 28px;\n height: 28px;\n padding: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n color: #fff;\n background: #1a1a1a;\n border: none;\n border-radius: 50%;\n cursor: pointer;\n\n &:hover:not(:disabled) {\n opacity: 0.9;\n }\n\n &:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n`;\n\nconst PoweredBy: ComponentType<React.AnchorHTMLAttributes<HTMLAnchorElement>> = styled.a`\n display: block;\n font-size: 8px;\n color: #888;\n text-decoration: none;\n padding: 4px 16px 4px 16px;\n text-align: center;\n cursor: pointer;\n\n &:hover {\n color: #1a1a1a;\n }\n`;\n\nexport {\n Container,\n WidgetButton,\n ChatbotContainer,\n Header,\n HeaderMarginBottom,\n ChatbotName,\n IconButton,\n MessageList,\n MessageBubble,\n Footer,\n InputContainerMarginTop,\n InputContainer,\n Textarea,\n InputContainerFooter,\n SendButton,\n PoweredBy,\n};\n","import React from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { PeppermintChatbot } from \"../react\";\n\n/**\n * Mount the chatbot into a container (vanilla JS, Vue, Svelte).\n * Requires react and react-dom to be available (e.g. via script or bundler).\n */\nexport function createChatbot(\n container: HTMLElement,\n props: {\n /** Layout: \"widget\" (bubble) or \"page\" (full card) */\n layout?: \"widget\" | \"page\";\n /** Chatbot display name */\n chatbotName?: string;\n /** Greeting message shown when chat is empty */\n greetingMessage?: string;\n /** Optional chatbot avatar URL */\n chatbotProfileImage?: string;\n /** Optional user avatar URL */\n userProfileImage?: string;\n /** Background color (hex) */\n backgroundColor?: string;\n /** Font color (hex) */\n fontColor?: string;\n /** Chatbot bubble color (hex) */\n chatbotBubbleColor?: string;\n /** User bubble color (hex) */\n userBubbleColor?: string;\n /** Initial messages (e.g. from API) */\n initialMessages?: {\n id: string;\n role: \"user\" | \"assistant\";\n content: string;\n timestamp?: string;\n }[];\n /** Callback when user sends a message */\n onSendMessage?: (content: string) => void;\n /** Optional class name for the root container */\n className?: string;\n } = {}\n): { unmount: () => void } {\n const root = createRoot(container);\n root.render(React.createElement(PeppermintChatbot, props));\n return {\n unmount: () => root.unmount(),\n };\n}\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA4C;;;ACA5C,+BAAmB;AAInB,IAAM,YAAiE,yBAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAU9E,IAAM,eAAuE,yBAAAA,QAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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