@a.izzuddin/ai-chat 0.2.3 → 0.2.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/README.md +166 -215
- package/README.npm.md +3 -3
- package/custom-elements.json +212 -0
- package/dist/index.d.mts +65 -1
- package/dist/index.d.ts +65 -1
- package/dist/index.js +417 -66
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +417 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -1
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
15
15
|
if (kind && result) __defProp(target, key, result);
|
|
16
16
|
return result;
|
|
17
17
|
};
|
|
18
|
-
var VERSION = "0.2.
|
|
18
|
+
var VERSION = "0.2.6";
|
|
19
19
|
exports.AIChat = class AIChat extends lit.LitElement {
|
|
20
20
|
constructor() {
|
|
21
21
|
super();
|
|
@@ -25,6 +25,14 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
25
25
|
this.theme = "light";
|
|
26
26
|
this.mode = "fullscreen";
|
|
27
27
|
this.initialMessages = [];
|
|
28
|
+
this.botAvatarUrl = "";
|
|
29
|
+
this.backgroundImageUrl = "";
|
|
30
|
+
this.widgetWidth = "380px";
|
|
31
|
+
this.widgetHeight = "600px";
|
|
32
|
+
this.primaryColor = "#3681D3";
|
|
33
|
+
this.primaryColorHover = "#3457C7";
|
|
34
|
+
this.userMessageBg = "#D6E4FF";
|
|
35
|
+
this.botMessageBg = "#F5F5F5";
|
|
28
36
|
this.messages = [];
|
|
29
37
|
this.input = "";
|
|
30
38
|
this.isLoading = false;
|
|
@@ -33,6 +41,16 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
33
41
|
toggleWidget() {
|
|
34
42
|
this.isOpen = !this.isOpen;
|
|
35
43
|
}
|
|
44
|
+
lightenColor(hex, percent = 15) {
|
|
45
|
+
hex = hex.replace("#", "");
|
|
46
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
47
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
48
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
49
|
+
const newR = Math.min(255, Math.round(r + (255 - r) * (percent / 100)));
|
|
50
|
+
const newG = Math.min(255, Math.round(g + (255 - g) * (percent / 100)));
|
|
51
|
+
const newB = Math.min(255, Math.round(b + (255 - b) * (percent / 100)));
|
|
52
|
+
return `#${newR.toString(16).padStart(2, "0")}${newG.toString(16).padStart(2, "0")}${newB.toString(16).padStart(2, "0")}`;
|
|
53
|
+
}
|
|
36
54
|
connectedCallback() {
|
|
37
55
|
super.connectedCallback();
|
|
38
56
|
if (this.initialMessages && this.initialMessages.length > 0) {
|
|
@@ -93,6 +111,7 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
93
111
|
console.log("\u{1F50D} Raw API response:", data);
|
|
94
112
|
let responseText = "No response from agent";
|
|
95
113
|
let faqs = void 0;
|
|
114
|
+
let suggestedQuestions = void 0;
|
|
96
115
|
if (data && typeof data === "object" && data.response && typeof data.response === "string") {
|
|
97
116
|
console.log("\u{1F4DD} data.response type:", typeof data.response);
|
|
98
117
|
console.log("\u{1F4DD} data.response preview:", data.response.substring(0, 100));
|
|
@@ -104,12 +123,15 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
104
123
|
console.log("\u2705 Parsed inner data with JSON.parse");
|
|
105
124
|
if (innerData && innerData.response && typeof innerData.response === "string") {
|
|
106
125
|
responseText = innerData.response;
|
|
107
|
-
faqs = innerData.faqs_used || void 0;
|
|
126
|
+
faqs = innerData.faq_used || innerData.faqs_used || void 0;
|
|
127
|
+
suggestedQuestions = innerData.suggested_follow_ups || innerData.suggested_questions || void 0;
|
|
108
128
|
console.log("\u2705 Extracted text length:", responseText.length);
|
|
109
129
|
console.log("\u2705 Extracted FAQs count:", faqs?.length || 0);
|
|
130
|
+
console.log("\u2705 Extracted suggested questions count:", suggestedQuestions?.length || 0);
|
|
110
131
|
} else {
|
|
111
132
|
responseText = data.response;
|
|
112
|
-
faqs = data.faqs_used || void 0;
|
|
133
|
+
faqs = data.faq_used || data.faqs_used || void 0;
|
|
134
|
+
suggestedQuestions = data.suggested_follow_ups || data.suggested_questions || void 0;
|
|
113
135
|
}
|
|
114
136
|
} catch (parseError) {
|
|
115
137
|
console.warn("\u26A0\uFE0F JSON.parse failed, using regex extraction...", parseError);
|
|
@@ -122,7 +144,7 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
122
144
|
console.error("\u274C Could not extract response");
|
|
123
145
|
responseText = "Error: Could not parse response";
|
|
124
146
|
}
|
|
125
|
-
const faqsPattern = /"faqs_used"\s*:\s*(\[[^\]]*\])/s;
|
|
147
|
+
const faqsPattern = /"(?:faq_used|faqs_used)"\s*:\s*(\[[^\]]*\])/s;
|
|
126
148
|
const faqsMatch = data.response.match(faqsPattern);
|
|
127
149
|
if (faqsMatch) {
|
|
128
150
|
try {
|
|
@@ -130,7 +152,7 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
130
152
|
console.log("\u2705 Extracted FAQs, count:", faqs?.length || 0);
|
|
131
153
|
} catch {
|
|
132
154
|
console.log("\u26A0\uFE0F Could not parse FAQs, trying multiline...");
|
|
133
|
-
const faqsMultiPattern = /"faqs_used"\s*:\s*(\[[\s\S]*?\n\s*\])/;
|
|
155
|
+
const faqsMultiPattern = /"(?:faq_used|faqs_used)"\s*:\s*(\[[\s\S]*?\n\s*\])/;
|
|
134
156
|
const faqsMultiMatch = data.response.match(faqsMultiPattern);
|
|
135
157
|
if (faqsMultiMatch) {
|
|
136
158
|
try {
|
|
@@ -142,11 +164,32 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
142
164
|
}
|
|
143
165
|
}
|
|
144
166
|
}
|
|
167
|
+
const suggestedPattern = /"(?:suggested_follow_ups|suggested_questions)"\s*:\s*(\[[^\]]*\])/s;
|
|
168
|
+
const suggestedMatch = data.response.match(suggestedPattern);
|
|
169
|
+
if (suggestedMatch) {
|
|
170
|
+
try {
|
|
171
|
+
suggestedQuestions = JSON.parse(suggestedMatch[1]);
|
|
172
|
+
console.log("\u2705 Extracted suggested questions, count:", suggestedQuestions?.length || 0);
|
|
173
|
+
} catch {
|
|
174
|
+
console.log("\u26A0\uFE0F Could not parse suggested questions, trying multiline...");
|
|
175
|
+
const suggestedMultiPattern = /"(?:suggested_follow_ups|suggested_questions)"\s*:\s*(\[[\s\S]*?\n\s*\])/;
|
|
176
|
+
const suggestedMultiMatch = data.response.match(suggestedMultiPattern);
|
|
177
|
+
if (suggestedMultiMatch) {
|
|
178
|
+
try {
|
|
179
|
+
suggestedQuestions = JSON.parse(suggestedMultiMatch[1]);
|
|
180
|
+
console.log("\u2705 Extracted multi-line suggested questions, count:", suggestedQuestions?.length || 0);
|
|
181
|
+
} catch {
|
|
182
|
+
suggestedQuestions = void 0;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
145
187
|
}
|
|
146
188
|
} else {
|
|
147
189
|
console.log("\u{1F4C4} Direct text response (not JSON)");
|
|
148
190
|
responseText = data.response;
|
|
149
|
-
faqs = data.faqs_used || void 0;
|
|
191
|
+
faqs = data.faq_used || data.faqs_used || void 0;
|
|
192
|
+
suggestedQuestions = data.suggested_follow_ups || data.suggested_questions || void 0;
|
|
150
193
|
}
|
|
151
194
|
} else if (typeof data === "string") {
|
|
152
195
|
console.log("\u{1F4C4} Response is a plain string");
|
|
@@ -154,15 +197,19 @@ exports.AIChat = class AIChat extends lit.LitElement {
|
|
|
154
197
|
} else if (data && typeof data === "object") {
|
|
155
198
|
console.warn("\u26A0\uFE0F Unexpected format, using fallback");
|
|
156
199
|
responseText = data.message || data.answer || "Error: Unexpected response format";
|
|
200
|
+
faqs = data.faq_used || data.faqs_used || void 0;
|
|
201
|
+
suggestedQuestions = data.suggested_follow_ups || data.suggested_questions || void 0;
|
|
157
202
|
}
|
|
158
203
|
console.log("\u{1F3AF} Final responseText length:", responseText.length);
|
|
159
204
|
console.log("\u{1F3AF} Final responseText preview:", responseText.substring(0, 100));
|
|
160
205
|
console.log("\u{1F3AF} Final FAQs:", faqs);
|
|
206
|
+
console.log("\u{1F3AF} Final suggested questions:", suggestedQuestions);
|
|
161
207
|
const assistantMessage = {
|
|
162
208
|
id: (Date.now() + 1).toString(),
|
|
163
209
|
role: "assistant",
|
|
164
210
|
content: responseText,
|
|
165
|
-
faqs
|
|
211
|
+
faqs,
|
|
212
|
+
suggestedQuestions
|
|
166
213
|
};
|
|
167
214
|
this.messages = [...this.messages, assistantMessage];
|
|
168
215
|
this.dispatchEvent(new CustomEvent("response-received", {
|
|
@@ -190,16 +237,22 @@ Please check your API endpoint configuration.`
|
|
|
190
237
|
}
|
|
191
238
|
}
|
|
192
239
|
renderChatUI() {
|
|
240
|
+
const primaryColorLight = this.lightenColor(this.primaryColor, 15);
|
|
193
241
|
return lit.html`
|
|
194
242
|
<!-- Header -->
|
|
195
|
-
<div class="header">
|
|
243
|
+
<div class="header" style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight}; --primary-color-hover: ${this.primaryColorHover};">
|
|
196
244
|
<div class="header-content">
|
|
245
|
+
<div class="header-avatar">
|
|
246
|
+
${this.botAvatarUrl ? lit.html`<img src="${this.botAvatarUrl}" alt="Bot" class="header-avatar-image" />` : lit.html`<svg viewBox="0 0 24 24" fill="none" stroke="${this.primaryColor}" stroke-width="2" style="width: 1.5rem; height: 1.5rem;">
|
|
247
|
+
<path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
|
|
248
|
+
</svg>`}
|
|
249
|
+
</div>
|
|
197
250
|
<h1 class="title">${this.chatTitle}</h1>
|
|
198
251
|
</div>
|
|
199
252
|
</div>
|
|
200
253
|
|
|
201
254
|
<!-- Messages Area -->
|
|
202
|
-
<div class="messages-area">
|
|
255
|
+
<div class="messages-area" style="--user-message-bg: ${this.userMessageBg}; --bot-message-bg: ${this.botMessageBg}; --primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight}; --primary-color-hover: ${this.primaryColorHover}; ${this.backgroundImageUrl ? `--background-image-url: url('${this.backgroundImageUrl}');` : ""}">
|
|
203
256
|
<div class="messages-container">
|
|
204
257
|
${this.messages.length === 0 ? lit.html`
|
|
205
258
|
<div class="empty-state">
|
|
@@ -214,7 +267,7 @@ Please check your API endpoint configuration.`
|
|
|
214
267
|
assistant: msg.role === "assistant"
|
|
215
268
|
})}>
|
|
216
269
|
<div class="avatar">
|
|
217
|
-
${msg.role === "user" ? "U" : "AI"}
|
|
270
|
+
${msg.role === "user" ? "U" : this.botAvatarUrl ? lit.html`<img src="${this.botAvatarUrl}" alt="AI" class="avatar-image" />` : "AI"}
|
|
218
271
|
</div>
|
|
219
272
|
<div class="message-content">
|
|
220
273
|
<p class="message-text">${msg.content}</p>
|
|
@@ -230,13 +283,27 @@ Please check your API endpoint configuration.`
|
|
|
230
283
|
</ul>
|
|
231
284
|
</div>
|
|
232
285
|
` : ""}
|
|
286
|
+
${msg.role === "assistant" && msg.suggestedQuestions && msg.suggestedQuestions.length > 0 ? lit.html`
|
|
287
|
+
<div class="faq-section">
|
|
288
|
+
<p class="faq-title">Suggested Questions:</p>
|
|
289
|
+
<ul class="faq-list">
|
|
290
|
+
${msg.suggestedQuestions.map((question) => lit.html`
|
|
291
|
+
<li class="faq-item" @click=${() => this.handleFAQClick(question)}>
|
|
292
|
+
${question}
|
|
293
|
+
</li>
|
|
294
|
+
`)}
|
|
295
|
+
</ul>
|
|
296
|
+
</div>
|
|
297
|
+
` : ""}
|
|
233
298
|
</div>
|
|
234
299
|
</div>
|
|
235
300
|
`)}
|
|
236
301
|
|
|
237
302
|
${this.isLoading ? lit.html`
|
|
238
303
|
<div class="loading">
|
|
239
|
-
<div class="avatar">
|
|
304
|
+
<div class="avatar">
|
|
305
|
+
${this.botAvatarUrl ? lit.html`<img src="${this.botAvatarUrl}" alt="AI" class="avatar-image" />` : "AI"}
|
|
306
|
+
</div>
|
|
240
307
|
<div class="message-content">
|
|
241
308
|
<div class="spinner"></div>
|
|
242
309
|
</div>
|
|
@@ -248,7 +315,7 @@ Please check your API endpoint configuration.`
|
|
|
248
315
|
</div>
|
|
249
316
|
|
|
250
317
|
<!-- Input Area -->
|
|
251
|
-
<div class="input-area">
|
|
318
|
+
<div class="input-area" style="--primary-color: ${this.primaryColor}; --primary-color-hover: ${this.primaryColorHover};">
|
|
252
319
|
<form class="input-form" @submit=${this.handleSubmit}>
|
|
253
320
|
<input
|
|
254
321
|
type="text"
|
|
@@ -281,17 +348,22 @@ Please check your API endpoint configuration.`
|
|
|
281
348
|
`;
|
|
282
349
|
}
|
|
283
350
|
render() {
|
|
351
|
+
const primaryColorLight = this.lightenColor(this.primaryColor, 15);
|
|
284
352
|
if (this.mode === "widget") {
|
|
285
353
|
return lit.html`
|
|
286
354
|
<div class="widget-container">
|
|
287
355
|
<!-- Chat Window -->
|
|
288
|
-
<div
|
|
356
|
+
<div
|
|
357
|
+
class=${classMap_js.classMap({ "widget-window": true, "open": this.isOpen })}
|
|
358
|
+
style="--widget-width: ${this.widgetWidth}; --widget-height: ${this.widgetHeight};"
|
|
359
|
+
>
|
|
289
360
|
${this.renderChatUI()}
|
|
290
361
|
</div>
|
|
291
362
|
|
|
292
363
|
<!-- Toggle Button -->
|
|
293
364
|
<button
|
|
294
365
|
class="widget-button"
|
|
366
|
+
style="--primary-color: ${this.primaryColor}; --primary-color-light: ${primaryColorLight};"
|
|
295
367
|
@click=${this.toggleWidget}
|
|
296
368
|
aria-label=${this.isOpen ? "Close chat" : "Open chat"}
|
|
297
369
|
>
|
|
@@ -323,7 +395,7 @@ exports.AIChat.styles = lit.css`
|
|
|
323
395
|
display: flex;
|
|
324
396
|
flex-direction: column;
|
|
325
397
|
height: 100vh;
|
|
326
|
-
background: #
|
|
398
|
+
background: #ffffff;
|
|
327
399
|
}
|
|
328
400
|
|
|
329
401
|
:host([mode="fullscreen"][theme="dark"]) {
|
|
@@ -347,19 +419,19 @@ exports.AIChat.styles = lit.css`
|
|
|
347
419
|
width: 60px;
|
|
348
420
|
height: 60px;
|
|
349
421
|
border-radius: 50%;
|
|
350
|
-
background: #
|
|
422
|
+
background: #3681D3;
|
|
351
423
|
border: none;
|
|
352
424
|
cursor: pointer;
|
|
353
425
|
display: flex;
|
|
354
426
|
align-items: center;
|
|
355
427
|
justify-content: center;
|
|
356
|
-
box-shadow: 0 4px
|
|
428
|
+
box-shadow: 0 4px 16px rgba(65, 105, 225, 0.3);
|
|
357
429
|
transition: transform 0.2s, box-shadow 0.2s;
|
|
358
430
|
}
|
|
359
431
|
|
|
360
432
|
.widget-button:hover {
|
|
361
433
|
transform: scale(1.05);
|
|
362
|
-
box-shadow: 0 6px
|
|
434
|
+
box-shadow: 0 6px 20px rgba(65, 105, 225, 0.4);
|
|
363
435
|
}
|
|
364
436
|
|
|
365
437
|
.widget-button svg {
|
|
@@ -372,11 +444,11 @@ exports.AIChat.styles = lit.css`
|
|
|
372
444
|
position: absolute;
|
|
373
445
|
bottom: 80px;
|
|
374
446
|
right: 0;
|
|
375
|
-
width: 380px;
|
|
376
|
-
height: 600px;
|
|
447
|
+
width: var(--widget-width, 380px);
|
|
448
|
+
height: var(--widget-height, 600px);
|
|
377
449
|
background: #fff;
|
|
378
|
-
border-radius:
|
|
379
|
-
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
|
|
450
|
+
border-radius: 16px;
|
|
451
|
+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.05);
|
|
380
452
|
display: flex;
|
|
381
453
|
flex-direction: column;
|
|
382
454
|
overflow: hidden;
|
|
@@ -397,41 +469,279 @@ exports.AIChat.styles = lit.css`
|
|
|
397
469
|
color: #fafafa;
|
|
398
470
|
}
|
|
399
471
|
|
|
400
|
-
|
|
472
|
+
/* Tablet breakpoint */
|
|
473
|
+
@media (max-width: 1024px) and (min-width: 769px) {
|
|
474
|
+
.widget-window {
|
|
475
|
+
width: var(--widget-width, 400px);
|
|
476
|
+
height: var(--widget-height, 650px);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/* Small tablet breakpoint */
|
|
481
|
+
@media (max-width: 768px) and (min-width: 481px) {
|
|
482
|
+
.widget-window {
|
|
483
|
+
width: var(--widget-width, 360px);
|
|
484
|
+
height: var(--widget-height, 550px);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/* Mobile portrait */
|
|
489
|
+
@media (max-width: 480px) and (orientation: portrait) {
|
|
401
490
|
.widget-window {
|
|
402
491
|
width: calc(100vw - 40px);
|
|
492
|
+
height: 70vh;
|
|
493
|
+
bottom: 80px;
|
|
494
|
+
right: 0;
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
.widget-button {
|
|
498
|
+
width: 56px;
|
|
499
|
+
height: 56px;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
.widget-button svg {
|
|
503
|
+
width: 24px;
|
|
504
|
+
height: 24px;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
/* Mobile landscape */
|
|
509
|
+
@media (max-width: 900px) and (orientation: landscape) {
|
|
510
|
+
.widget-window {
|
|
511
|
+
width: var(--widget-width, 500px);
|
|
403
512
|
height: calc(100vh - 100px);
|
|
404
513
|
bottom: 80px;
|
|
405
514
|
right: 0;
|
|
406
515
|
}
|
|
516
|
+
|
|
517
|
+
.widget-button {
|
|
518
|
+
width: 56px;
|
|
519
|
+
height: 56px;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.widget-button svg {
|
|
523
|
+
width: 24px;
|
|
524
|
+
height: 24px;
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
/* Mobile responsive styles for all modes */
|
|
529
|
+
@media (max-width: 768px) {
|
|
530
|
+
.header {
|
|
531
|
+
padding: 0.875rem 1rem;
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
.header-avatar {
|
|
535
|
+
width: 2.25rem;
|
|
536
|
+
height: 2.25rem;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.title {
|
|
540
|
+
font-size: 1.125rem;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.messages-area {
|
|
544
|
+
padding: 1rem 0.75rem;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.message {
|
|
548
|
+
gap: 0.75rem;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
.avatar {
|
|
552
|
+
width: 2rem;
|
|
553
|
+
height: 2rem;
|
|
554
|
+
font-size: 0.75rem;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
.message-content {
|
|
558
|
+
max-width: 100%;
|
|
559
|
+
padding: 0.625rem 0.875rem;
|
|
560
|
+
font-size: 0.9375rem;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.empty-state {
|
|
564
|
+
margin-top: 3rem;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
.empty-state p {
|
|
568
|
+
font-size: 1.25rem;
|
|
569
|
+
padding: 0 1rem;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
.faq-section {
|
|
573
|
+
margin-top: 0.75rem;
|
|
574
|
+
padding-top: 0.75rem;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.faq-item {
|
|
578
|
+
font-size: 0.8125rem;
|
|
579
|
+
padding: 0.375rem;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.input-area {
|
|
583
|
+
padding: 0.75rem;
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.input-form {
|
|
587
|
+
gap: 0.5rem;
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
.input-field {
|
|
591
|
+
height: 2.75rem;
|
|
592
|
+
padding: 0 0.875rem;
|
|
593
|
+
font-size: 0.9375rem;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
.send-button {
|
|
597
|
+
width: 2.75rem;
|
|
598
|
+
height: 2.75rem;
|
|
599
|
+
flex-shrink: 0;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
.send-icon {
|
|
603
|
+
width: 1.125rem;
|
|
604
|
+
height: 1.125rem;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/* Extra small screens */
|
|
609
|
+
@media (max-width: 480px) {
|
|
610
|
+
.header {
|
|
611
|
+
padding: 0.75rem 0.875rem;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
.header-avatar {
|
|
615
|
+
width: 2rem;
|
|
616
|
+
height: 2rem;
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
.title {
|
|
620
|
+
font-size: 1rem;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
.messages-area {
|
|
624
|
+
padding: 0.75rem 0.5rem;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
.message {
|
|
628
|
+
gap: 0.5rem;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
.avatar {
|
|
632
|
+
width: 1.75rem;
|
|
633
|
+
height: 1.75rem;
|
|
634
|
+
font-size: 0.7rem;
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
.message-content {
|
|
638
|
+
padding: 0.5rem 0.75rem;
|
|
639
|
+
font-size: 0.875rem;
|
|
640
|
+
border-radius: 0.75rem;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
.empty-state {
|
|
644
|
+
margin-top: 2rem;
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
.empty-state p {
|
|
648
|
+
font-size: 1.125rem;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
.input-area {
|
|
652
|
+
padding: 0.625rem;
|
|
653
|
+
}
|
|
654
|
+
|
|
655
|
+
.input-field {
|
|
656
|
+
height: 2.5rem;
|
|
657
|
+
padding: 0 0.75rem;
|
|
658
|
+
font-size: 0.875rem;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
.send-button {
|
|
662
|
+
width: 2.5rem;
|
|
663
|
+
height: 2.5rem;
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
.version-tag {
|
|
667
|
+
font-size: 0.7rem;
|
|
668
|
+
padding: 0.375rem;
|
|
669
|
+
}
|
|
407
670
|
}
|
|
408
671
|
|
|
409
672
|
.header {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
673
|
+
background:#3681D3;
|
|
674
|
+
padding: 1rem 1.25rem;
|
|
675
|
+
display: flex;
|
|
676
|
+
align-items: center;
|
|
677
|
+
gap: 0.75rem;
|
|
678
|
+
box-shadow: 0 2px 8px rgba(65, 105, 225, 0.2);
|
|
413
679
|
}
|
|
414
680
|
|
|
415
681
|
:host([theme="dark"]) .header {
|
|
416
|
-
|
|
417
|
-
background: #18181b;
|
|
682
|
+
background: #3681D3
|
|
418
683
|
}
|
|
419
684
|
|
|
420
685
|
.header-content {
|
|
421
686
|
max-width: 56rem;
|
|
422
687
|
margin: 0 auto;
|
|
688
|
+
display: flex;
|
|
689
|
+
align-items: center;
|
|
690
|
+
gap: 0.75rem;
|
|
691
|
+
width: 100%;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
.header-avatar {
|
|
695
|
+
width: 2.5rem;
|
|
696
|
+
height: 2.5rem;
|
|
697
|
+
border-radius: 50%;
|
|
698
|
+
background: #fff;
|
|
699
|
+
display: flex;
|
|
700
|
+
align-items: center;
|
|
701
|
+
justify-content: center;
|
|
702
|
+
overflow: hidden;
|
|
703
|
+
flex-shrink: 0;
|
|
704
|
+
}
|
|
705
|
+
|
|
706
|
+
.header-avatar-image {
|
|
707
|
+
width: 100%;
|
|
708
|
+
height: 100%;
|
|
709
|
+
object-fit: cover;
|
|
423
710
|
}
|
|
424
711
|
|
|
425
712
|
.title {
|
|
426
713
|
font-size: 1.25rem;
|
|
427
714
|
font-weight: 600;
|
|
428
715
|
margin: 0;
|
|
716
|
+
color: #fff;
|
|
429
717
|
}
|
|
430
718
|
|
|
431
719
|
.messages-area {
|
|
432
720
|
flex: 1;
|
|
433
721
|
overflow-y: auto;
|
|
434
722
|
padding: 1.5rem 1rem;
|
|
723
|
+
position: relative;
|
|
724
|
+
background: #ffffff;
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
:host([theme="dark"]) .messages-area {
|
|
728
|
+
background: #000;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
.messages-area::before {
|
|
732
|
+
content: '';
|
|
733
|
+
position: absolute;
|
|
734
|
+
top: 0;
|
|
735
|
+
left: 0;
|
|
736
|
+
right: 0;
|
|
737
|
+
bottom: 0;
|
|
738
|
+
background-image: var(--background-image-url);
|
|
739
|
+
background-size: 200px auto 60%;
|
|
740
|
+
background-position: center center;
|
|
741
|
+
background-repeat: no-repeat;
|
|
742
|
+
opacity: 0.03;
|
|
743
|
+
pointer-events: none;
|
|
744
|
+
z-index: 0;
|
|
435
745
|
}
|
|
436
746
|
|
|
437
747
|
.messages-container {
|
|
@@ -440,11 +750,13 @@ exports.AIChat.styles = lit.css`
|
|
|
440
750
|
display: flex;
|
|
441
751
|
flex-direction: column;
|
|
442
752
|
gap: 1.5rem;
|
|
753
|
+
position: relative;
|
|
754
|
+
z-index: 1;
|
|
443
755
|
}
|
|
444
756
|
|
|
445
757
|
.empty-state {
|
|
446
758
|
text-align: center;
|
|
447
|
-
color: #
|
|
759
|
+
color: #9ca3af;
|
|
448
760
|
margin-top: 5rem;
|
|
449
761
|
}
|
|
450
762
|
|
|
@@ -471,39 +783,54 @@ exports.AIChat.styles = lit.css`
|
|
|
471
783
|
width: 2.5rem;
|
|
472
784
|
height: 2.5rem;
|
|
473
785
|
border-radius: 9999px;
|
|
474
|
-
background: #
|
|
786
|
+
background: #E5E7EB;
|
|
475
787
|
display: flex;
|
|
476
788
|
align-items: center;
|
|
477
789
|
justify-content: center;
|
|
478
790
|
flex-shrink: 0;
|
|
479
|
-
font-weight:
|
|
791
|
+
font-weight: 600;
|
|
480
792
|
font-size: 0.875rem;
|
|
793
|
+
overflow: hidden;
|
|
794
|
+
color: #6B7280;
|
|
481
795
|
}
|
|
482
796
|
|
|
483
797
|
:host([theme="dark"]) .avatar {
|
|
484
798
|
background: #3f3f46;
|
|
799
|
+
color: #9ca3af;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
.avatar-image {
|
|
803
|
+
width: 100%;
|
|
804
|
+
height: 100%;
|
|
805
|
+
object-fit: cover;
|
|
485
806
|
}
|
|
486
807
|
|
|
487
808
|
.message-content {
|
|
488
809
|
max-width: 36rem;
|
|
489
|
-
padding: 0.
|
|
490
|
-
border-radius:
|
|
810
|
+
padding: 0.875rem 1.125rem;
|
|
811
|
+
border-radius: 1.25rem;
|
|
812
|
+
line-height: 1.6;
|
|
491
813
|
}
|
|
492
814
|
|
|
493
815
|
.message.user .message-content {
|
|
494
|
-
background: #
|
|
495
|
-
color: #
|
|
816
|
+
background: var(--user-message-bg, #D6E4FF);
|
|
817
|
+
color: #1a1a1a;
|
|
818
|
+
border-radius: 1.25rem 1.25rem 0.25rem 1.25rem;
|
|
496
819
|
}
|
|
497
820
|
|
|
498
821
|
.message.assistant .message-content {
|
|
499
|
-
background: #
|
|
500
|
-
|
|
501
|
-
|
|
822
|
+
background: var(--bot-message-bg, #F5F5F5);
|
|
823
|
+
color: #1a1a1a;
|
|
824
|
+
border-radius: 1.25rem 1.25rem 1.25rem 0.25rem;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
:host([theme="dark"]) .message.user .message-content {
|
|
828
|
+
background: #3D5A99;
|
|
829
|
+
color: #fff;
|
|
502
830
|
}
|
|
503
831
|
|
|
504
832
|
:host([theme="dark"]) .message.assistant .message-content {
|
|
505
833
|
background: #27272a;
|
|
506
|
-
border-color: #3f3f46;
|
|
507
834
|
color: #fafafa;
|
|
508
835
|
}
|
|
509
836
|
|
|
@@ -515,7 +842,7 @@ exports.AIChat.styles = lit.css`
|
|
|
515
842
|
.faq-section {
|
|
516
843
|
margin-top: 1rem;
|
|
517
844
|
padding-top: 1rem;
|
|
518
|
-
border-top: 1px solid #
|
|
845
|
+
border-top: 1px solid #d1d5db;
|
|
519
846
|
}
|
|
520
847
|
|
|
521
848
|
:host([theme="dark"]) .faq-section {
|
|
@@ -524,13 +851,13 @@ exports.AIChat.styles = lit.css`
|
|
|
524
851
|
|
|
525
852
|
.faq-title {
|
|
526
853
|
font-size: 0.875rem;
|
|
527
|
-
font-weight:
|
|
528
|
-
color: #
|
|
854
|
+
font-weight: 600;
|
|
855
|
+
color: var(--primary-color, #3681D3);
|
|
529
856
|
margin: 0 0 0.5rem 0;
|
|
530
857
|
}
|
|
531
858
|
|
|
532
859
|
:host([theme="dark"]) .faq-title {
|
|
533
|
-
color: #
|
|
860
|
+
color: var(--primary-color-light, #5B7FE8);
|
|
534
861
|
}
|
|
535
862
|
|
|
536
863
|
.faq-list {
|
|
@@ -544,25 +871,28 @@ exports.AIChat.styles = lit.css`
|
|
|
544
871
|
|
|
545
872
|
.faq-item {
|
|
546
873
|
font-size: 0.875rem;
|
|
547
|
-
color: #
|
|
548
|
-
padding: 0.5rem;
|
|
549
|
-
border-radius: 0.
|
|
874
|
+
color: var(--primary-color, #3681D3);
|
|
875
|
+
padding: 0.5rem 0.75rem;
|
|
876
|
+
border-radius: 0.5rem;
|
|
550
877
|
cursor: pointer;
|
|
551
878
|
transition: background-color 0.2s, color 0.2s;
|
|
879
|
+
border: 1px solid transparent;
|
|
552
880
|
}
|
|
553
881
|
|
|
554
882
|
.faq-item:hover {
|
|
555
|
-
background-color: #
|
|
556
|
-
color: #
|
|
883
|
+
background-color: #EEF2FF;
|
|
884
|
+
color: var(--primary-color-hover, #3457C7);
|
|
885
|
+
border-color: #C7D2FE;
|
|
557
886
|
}
|
|
558
887
|
|
|
559
888
|
:host([theme="dark"]) .faq-item {
|
|
560
|
-
color: #
|
|
889
|
+
color: var(--primary-color-light, #5B7FE8);
|
|
561
890
|
}
|
|
562
891
|
|
|
563
892
|
:host([theme="dark"]) .faq-item:hover {
|
|
564
|
-
background-color: #
|
|
565
|
-
color: #
|
|
893
|
+
background-color: #1e293b;
|
|
894
|
+
color: #93C5FD;
|
|
895
|
+
border-color: #3f3f46;
|
|
566
896
|
}
|
|
567
897
|
|
|
568
898
|
.loading {
|
|
@@ -585,14 +915,14 @@ exports.AIChat.styles = lit.css`
|
|
|
585
915
|
}
|
|
586
916
|
|
|
587
917
|
.input-area {
|
|
588
|
-
border-top: 1px solid #
|
|
918
|
+
border-top: 1px solid #e5e7eb;
|
|
589
919
|
background: #fff;
|
|
590
|
-
padding: 1rem;
|
|
920
|
+
padding: 1rem 1.25rem;
|
|
591
921
|
}
|
|
592
922
|
|
|
593
923
|
:host([theme="dark"]) .input-area {
|
|
594
924
|
border-top-color: #27272a;
|
|
595
|
-
background: #
|
|
925
|
+
background: #18181b;
|
|
596
926
|
}
|
|
597
927
|
|
|
598
928
|
.input-form {
|
|
@@ -600,18 +930,24 @@ exports.AIChat.styles = lit.css`
|
|
|
600
930
|
margin: 0 auto;
|
|
601
931
|
display: flex;
|
|
602
932
|
gap: 0.75rem;
|
|
933
|
+
align-items: center;
|
|
603
934
|
}
|
|
604
935
|
|
|
605
936
|
.input-field {
|
|
606
937
|
flex: 1;
|
|
607
938
|
height: 3rem;
|
|
608
939
|
padding: 0 1rem;
|
|
609
|
-
border: 1px solid #
|
|
610
|
-
border-radius:
|
|
611
|
-
font-size:
|
|
940
|
+
border: 1px solid #d1d5db;
|
|
941
|
+
border-radius: 1.5rem;
|
|
942
|
+
font-size: 0.9375rem;
|
|
612
943
|
font-family: inherit;
|
|
613
944
|
background: #fff;
|
|
614
|
-
color: #
|
|
945
|
+
color: #374151;
|
|
946
|
+
transition: border-color 0.2s, box-shadow 0.2s;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
.input-field::placeholder {
|
|
950
|
+
color: #9ca3af;
|
|
615
951
|
}
|
|
616
952
|
|
|
617
953
|
:host([theme="dark"]) .input-field {
|
|
@@ -621,8 +957,9 @@ exports.AIChat.styles = lit.css`
|
|
|
621
957
|
}
|
|
622
958
|
|
|
623
959
|
.input-field:focus {
|
|
624
|
-
outline:
|
|
625
|
-
|
|
960
|
+
outline: none;
|
|
961
|
+
border-color: var(--primary-color, #3681D3);
|
|
962
|
+
box-shadow: 0 0 0 3px rgba(65, 105, 225, 0.1);
|
|
626
963
|
}
|
|
627
964
|
|
|
628
965
|
.input-field:disabled {
|
|
@@ -635,17 +972,23 @@ exports.AIChat.styles = lit.css`
|
|
|
635
972
|
height: 3rem;
|
|
636
973
|
border-radius: 9999px;
|
|
637
974
|
border: none;
|
|
638
|
-
background: #
|
|
975
|
+
background: var(--primary-color, #3681D3);
|
|
639
976
|
color: #fff;
|
|
640
977
|
cursor: pointer;
|
|
641
978
|
display: flex;
|
|
642
979
|
align-items: center;
|
|
643
980
|
justify-content: center;
|
|
644
|
-
transition: background 0.2s;
|
|
981
|
+
transition: background 0.2s, transform 0.1s;
|
|
982
|
+
flex-shrink: 0;
|
|
645
983
|
}
|
|
646
984
|
|
|
647
985
|
.send-button:hover:not(:disabled) {
|
|
648
|
-
background: #
|
|
986
|
+
background: var(--primary-color-hover, #3457C7);
|
|
987
|
+
transform: scale(1.05);
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
.send-button:active:not(:disabled) {
|
|
991
|
+
transform: scale(0.95);
|
|
649
992
|
}
|
|
650
993
|
|
|
651
994
|
.send-button:disabled {
|
|
@@ -662,12 +1005,12 @@ exports.AIChat.styles = lit.css`
|
|
|
662
1005
|
text-align: center;
|
|
663
1006
|
padding: 0.5rem;
|
|
664
1007
|
font-size: 0.75rem;
|
|
665
|
-
color: #
|
|
666
|
-
border-top: 1px solid #
|
|
1008
|
+
color: #9ca3af;
|
|
1009
|
+
border-top: 1px solid #e5e7eb;
|
|
667
1010
|
}
|
|
668
1011
|
|
|
669
1012
|
:host([theme="dark"]) .version-tag {
|
|
670
|
-
color: #
|
|
1013
|
+
color: #6b7280;
|
|
671
1014
|
border-top-color: #27272a;
|
|
672
1015
|
}
|
|
673
1016
|
`;
|
|
@@ -677,7 +1020,15 @@ exports.AIChat.properties = {
|
|
|
677
1020
|
chatTitle: { type: String, attribute: "title" },
|
|
678
1021
|
theme: { type: String },
|
|
679
1022
|
mode: { type: String, reflect: true },
|
|
680
|
-
initialMessages: { type: Array }
|
|
1023
|
+
initialMessages: { type: Array },
|
|
1024
|
+
botAvatarUrl: { type: String, attribute: "bot-avatar-url" },
|
|
1025
|
+
backgroundImageUrl: { type: String, attribute: "background-image-url" },
|
|
1026
|
+
widgetWidth: { type: String, attribute: "widget-width" },
|
|
1027
|
+
widgetHeight: { type: String, attribute: "widget-height" },
|
|
1028
|
+
primaryColor: { type: String, attribute: "primary-color" },
|
|
1029
|
+
primaryColorHover: { type: String, attribute: "primary-color-hover" },
|
|
1030
|
+
userMessageBg: { type: String, attribute: "user-message-bg" },
|
|
1031
|
+
botMessageBg: { type: String, attribute: "bot-message-bg" }
|
|
681
1032
|
};
|
|
682
1033
|
__decorateClass([
|
|
683
1034
|
decorators_js.state()
|