@contenify/chatbot 0.1.4 → 1.0.0
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 +3 -2
- package/dist/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +831 -557
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +842 -573
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +408 -28
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -19,6 +19,9 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
};
|
|
20
20
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
21
21
|
|
|
22
|
+
// src/index.tsx
|
|
23
|
+
import { useEffect as useEffect8 } from "react";
|
|
24
|
+
|
|
22
25
|
// contexts/PreferencesContext.tsx
|
|
23
26
|
import { createContext, useContext, useState, useEffect } from "react";
|
|
24
27
|
|
|
@@ -26,12 +29,22 @@ import { createContext, useContext, useState, useEffect } from "react";
|
|
|
26
29
|
import axios from "axios";
|
|
27
30
|
|
|
28
31
|
// lib/config.ts
|
|
32
|
+
var _apiUrl = process.env.NEXT_PUBLIC_CONTENIFY_API_URL || "http://localhost:8080/api";
|
|
33
|
+
var _apiKey = process.env.NEXT_PUBLIC_API_KEY || "";
|
|
34
|
+
var _domain = process.env.NEXT_PUBLIC_DOMAIN || "";
|
|
35
|
+
function setConfig(config) {
|
|
36
|
+
if (config.apiUrl) _apiUrl = config.apiUrl;
|
|
37
|
+
if (config.apiKey) _apiKey = config.apiKey;
|
|
38
|
+
if (config.domain) _domain = config.domain;
|
|
39
|
+
}
|
|
29
40
|
function getApiBaseUrl() {
|
|
30
|
-
return
|
|
41
|
+
return _apiUrl;
|
|
31
42
|
}
|
|
32
43
|
function getServerBaseUrl() {
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
return _apiUrl.replace(/\/api\/?$/, "");
|
|
45
|
+
}
|
|
46
|
+
function getApiKey() {
|
|
47
|
+
return _apiKey;
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
// lib/api.ts
|
|
@@ -44,7 +57,7 @@ var api = axios.create({
|
|
|
44
57
|
});
|
|
45
58
|
api.interceptors.request.use(
|
|
46
59
|
(config) => {
|
|
47
|
-
const apiKey =
|
|
60
|
+
const apiKey = getApiKey();
|
|
48
61
|
if (apiKey) {
|
|
49
62
|
config.headers["x-api-key"] = apiKey;
|
|
50
63
|
}
|
|
@@ -67,6 +80,88 @@ var getMyPreferencesApi = async () => {
|
|
|
67
80
|
const { data } = await api_default.get("/preferences/me");
|
|
68
81
|
return data.data;
|
|
69
82
|
};
|
|
83
|
+
var savePreferencesApi = async ({
|
|
84
|
+
botName,
|
|
85
|
+
logo,
|
|
86
|
+
state,
|
|
87
|
+
cities,
|
|
88
|
+
primaryColor,
|
|
89
|
+
secondaryColor,
|
|
90
|
+
theme,
|
|
91
|
+
language,
|
|
92
|
+
showSidebar,
|
|
93
|
+
showHeader,
|
|
94
|
+
activeThemePreset,
|
|
95
|
+
showNewsPanel,
|
|
96
|
+
tone,
|
|
97
|
+
style,
|
|
98
|
+
wordCount,
|
|
99
|
+
includeQuotes,
|
|
100
|
+
includeFAQ,
|
|
101
|
+
targetAudience
|
|
102
|
+
}) => {
|
|
103
|
+
const formData = new FormData();
|
|
104
|
+
if (botName) {
|
|
105
|
+
formData.append("botName", botName);
|
|
106
|
+
}
|
|
107
|
+
if (logo) {
|
|
108
|
+
formData.append("logo", logo);
|
|
109
|
+
}
|
|
110
|
+
if (state) {
|
|
111
|
+
formData.append("state", state);
|
|
112
|
+
}
|
|
113
|
+
if (cities) {
|
|
114
|
+
formData.append("cities", JSON.stringify(cities));
|
|
115
|
+
}
|
|
116
|
+
if (primaryColor) {
|
|
117
|
+
formData.append("primaryColor", primaryColor);
|
|
118
|
+
}
|
|
119
|
+
if (secondaryColor) {
|
|
120
|
+
formData.append("secondaryColor", secondaryColor);
|
|
121
|
+
}
|
|
122
|
+
if (theme) {
|
|
123
|
+
formData.append("theme", theme);
|
|
124
|
+
}
|
|
125
|
+
if (language) {
|
|
126
|
+
formData.append("language", language);
|
|
127
|
+
}
|
|
128
|
+
if (showSidebar !== void 0) {
|
|
129
|
+
formData.append("showSidebar", String(showSidebar));
|
|
130
|
+
}
|
|
131
|
+
if (showHeader !== void 0) {
|
|
132
|
+
formData.append("showHeader", String(showHeader));
|
|
133
|
+
}
|
|
134
|
+
if (activeThemePreset !== void 0) {
|
|
135
|
+
formData.append("activeThemePreset", activeThemePreset != null ? activeThemePreset : "");
|
|
136
|
+
}
|
|
137
|
+
if (showNewsPanel !== void 0) {
|
|
138
|
+
formData.append("showNewsPanel", String(showNewsPanel));
|
|
139
|
+
}
|
|
140
|
+
if (tone) {
|
|
141
|
+
formData.append("tone", tone);
|
|
142
|
+
}
|
|
143
|
+
if (style) {
|
|
144
|
+
formData.append("style", style);
|
|
145
|
+
}
|
|
146
|
+
if (wordCount) {
|
|
147
|
+
formData.append("wordCount", wordCount);
|
|
148
|
+
}
|
|
149
|
+
if (includeQuotes !== void 0) {
|
|
150
|
+
formData.append("includeQuotes", String(includeQuotes));
|
|
151
|
+
}
|
|
152
|
+
if (includeFAQ !== void 0) {
|
|
153
|
+
formData.append("includeFAQ", String(includeFAQ));
|
|
154
|
+
}
|
|
155
|
+
if (targetAudience !== void 0) {
|
|
156
|
+
formData.append("targetAudience", targetAudience);
|
|
157
|
+
}
|
|
158
|
+
const { data } = await api_default.put("/preferences", formData, {
|
|
159
|
+
headers: {
|
|
160
|
+
"Content-Type": "multipart/form-data"
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
return data.data;
|
|
164
|
+
};
|
|
70
165
|
|
|
71
166
|
// contexts/PreferencesContext.tsx
|
|
72
167
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -169,59 +264,7 @@ function usePreferences() {
|
|
|
169
264
|
}
|
|
170
265
|
|
|
171
266
|
// components/chatbot/ChatBot.tsx
|
|
172
|
-
import { useState as
|
|
173
|
-
|
|
174
|
-
// components/chatbot/ArticleModal.tsx
|
|
175
|
-
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
176
|
-
function ArticleModal({
|
|
177
|
-
article,
|
|
178
|
-
onClose,
|
|
179
|
-
onRecreate
|
|
180
|
-
}) {
|
|
181
|
-
return /* @__PURE__ */ jsx2("div", { className: "cnfy-article-modal-overlay", children: /* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal", children: [
|
|
182
|
-
/* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal-header", children: [
|
|
183
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
184
|
-
/* @__PURE__ */ jsx2("p", { className: "cnfy-article-modal-source", children: "Source Article" }),
|
|
185
|
-
/* @__PURE__ */ jsx2("h2", { className: "cnfy-article-modal-title", children: article.title })
|
|
186
|
-
] }),
|
|
187
|
-
/* @__PURE__ */ jsx2(
|
|
188
|
-
"button",
|
|
189
|
-
{
|
|
190
|
-
onClick: onClose,
|
|
191
|
-
className: "cnfy-article-modal-close-btn",
|
|
192
|
-
"aria-label": "Close modal",
|
|
193
|
-
children: "\u2715"
|
|
194
|
-
}
|
|
195
|
-
)
|
|
196
|
-
] }),
|
|
197
|
-
/* @__PURE__ */ jsx2("div", { className: "cnfy-article-modal-body", children: /* @__PURE__ */ jsx2("div", { className: "cnfy-article-modal-content", children: article.content }) }),
|
|
198
|
-
/* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal-footer", children: [
|
|
199
|
-
/* @__PURE__ */ jsx2("span", { className: "cnfy-article-modal-footer-text", children: "This content will be recreated using AI" }),
|
|
200
|
-
/* @__PURE__ */ jsxs("div", { className: "cnfy-article-modal-footer-actions", children: [
|
|
201
|
-
/* @__PURE__ */ jsx2(
|
|
202
|
-
"button",
|
|
203
|
-
{
|
|
204
|
-
onClick: onClose,
|
|
205
|
-
className: "cnfy-btn-cancel",
|
|
206
|
-
children: "Cancel"
|
|
207
|
-
}
|
|
208
|
-
),
|
|
209
|
-
/* @__PURE__ */ jsx2(
|
|
210
|
-
"button",
|
|
211
|
-
{
|
|
212
|
-
onClick: () => onRecreate({
|
|
213
|
-
title: article.title,
|
|
214
|
-
content: article.content,
|
|
215
|
-
id: article._id
|
|
216
|
-
}),
|
|
217
|
-
className: "cnfy-btn-recreate",
|
|
218
|
-
children: "Recreate Article"
|
|
219
|
-
}
|
|
220
|
-
)
|
|
221
|
-
] })
|
|
222
|
-
] })
|
|
223
|
-
] }) });
|
|
224
|
-
}
|
|
267
|
+
import { useState as useState7 } from "react";
|
|
225
268
|
|
|
226
269
|
// util/util.ts
|
|
227
270
|
function extractArticleContent(raw) {
|
|
@@ -274,7 +317,7 @@ import {
|
|
|
274
317
|
Pilcrow
|
|
275
318
|
} from "lucide-react";
|
|
276
319
|
import { useEffect as useEffect2 } from "react";
|
|
277
|
-
import { jsx as
|
|
320
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
278
321
|
function RichTextEditor({
|
|
279
322
|
content,
|
|
280
323
|
onChange,
|
|
@@ -309,96 +352,96 @@ function RichTextEditor({
|
|
|
309
352
|
}
|
|
310
353
|
}, [content, editor]);
|
|
311
354
|
if (!editor) {
|
|
312
|
-
return /* @__PURE__ */
|
|
355
|
+
return /* @__PURE__ */ jsx2("div", { className: "cnfy-editor-loading", children: "Loading editor..." });
|
|
313
356
|
}
|
|
314
|
-
return /* @__PURE__ */
|
|
315
|
-
/* @__PURE__ */
|
|
316
|
-
/* @__PURE__ */
|
|
357
|
+
return /* @__PURE__ */ jsxs("div", { className: "cnfy-editor", children: [
|
|
358
|
+
/* @__PURE__ */ jsxs("div", { className: "cnfy-toolbar", children: [
|
|
359
|
+
/* @__PURE__ */ jsx2(
|
|
317
360
|
ToolbarButton,
|
|
318
361
|
{
|
|
319
362
|
onClick: () => editor.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
320
363
|
isActive: editor.isActive("heading", { level: 1 }),
|
|
321
364
|
title: "Heading 1",
|
|
322
|
-
children: /* @__PURE__ */
|
|
365
|
+
children: /* @__PURE__ */ jsx2(Heading1, { size: 18 })
|
|
323
366
|
}
|
|
324
367
|
),
|
|
325
|
-
/* @__PURE__ */
|
|
368
|
+
/* @__PURE__ */ jsx2(
|
|
326
369
|
ToolbarButton,
|
|
327
370
|
{
|
|
328
371
|
onClick: () => editor.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
329
372
|
isActive: editor.isActive("heading", { level: 2 }),
|
|
330
373
|
title: "Heading 2",
|
|
331
|
-
children: /* @__PURE__ */
|
|
374
|
+
children: /* @__PURE__ */ jsx2(Heading2, { size: 18 })
|
|
332
375
|
}
|
|
333
376
|
),
|
|
334
|
-
/* @__PURE__ */
|
|
377
|
+
/* @__PURE__ */ jsx2(
|
|
335
378
|
ToolbarButton,
|
|
336
379
|
{
|
|
337
380
|
onClick: () => editor.chain().focus().setParagraph().run(),
|
|
338
381
|
isActive: editor.isActive("paragraph"),
|
|
339
382
|
title: "Paragraph",
|
|
340
|
-
children: /* @__PURE__ */
|
|
383
|
+
children: /* @__PURE__ */ jsx2(Pilcrow, { size: 18 })
|
|
341
384
|
}
|
|
342
385
|
),
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ jsx2("div", { className: "cnfy-toolbar-divider" }),
|
|
387
|
+
/* @__PURE__ */ jsx2(
|
|
345
388
|
ToolbarButton,
|
|
346
389
|
{
|
|
347
390
|
onClick: () => editor.chain().focus().toggleBold().run(),
|
|
348
391
|
isActive: editor.isActive("bold"),
|
|
349
392
|
title: "Bold",
|
|
350
|
-
children: /* @__PURE__ */
|
|
393
|
+
children: /* @__PURE__ */ jsx2(Bold, { size: 18 })
|
|
351
394
|
}
|
|
352
395
|
),
|
|
353
|
-
/* @__PURE__ */
|
|
396
|
+
/* @__PURE__ */ jsx2(
|
|
354
397
|
ToolbarButton,
|
|
355
398
|
{
|
|
356
399
|
onClick: () => editor.chain().focus().toggleItalic().run(),
|
|
357
400
|
isActive: editor.isActive("italic"),
|
|
358
401
|
title: "Italic",
|
|
359
|
-
children: /* @__PURE__ */
|
|
402
|
+
children: /* @__PURE__ */ jsx2(Italic, { size: 18 })
|
|
360
403
|
}
|
|
361
404
|
),
|
|
362
|
-
/* @__PURE__ */
|
|
363
|
-
/* @__PURE__ */
|
|
405
|
+
/* @__PURE__ */ jsx2("div", { className: "cnfy-toolbar-divider" }),
|
|
406
|
+
/* @__PURE__ */ jsx2(
|
|
364
407
|
ToolbarButton,
|
|
365
408
|
{
|
|
366
409
|
onClick: () => editor.chain().focus().toggleBulletList().run(),
|
|
367
410
|
isActive: editor.isActive("bulletList"),
|
|
368
411
|
title: "Bullet List",
|
|
369
|
-
children: /* @__PURE__ */
|
|
412
|
+
children: /* @__PURE__ */ jsx2(List, { size: 18 })
|
|
370
413
|
}
|
|
371
414
|
),
|
|
372
|
-
/* @__PURE__ */
|
|
415
|
+
/* @__PURE__ */ jsx2(
|
|
373
416
|
ToolbarButton,
|
|
374
417
|
{
|
|
375
418
|
onClick: () => editor.chain().focus().toggleOrderedList().run(),
|
|
376
419
|
isActive: editor.isActive("orderedList"),
|
|
377
420
|
title: "Numbered List",
|
|
378
|
-
children: /* @__PURE__ */
|
|
421
|
+
children: /* @__PURE__ */ jsx2(ListOrdered, { size: 18 })
|
|
379
422
|
}
|
|
380
423
|
),
|
|
381
|
-
/* @__PURE__ */
|
|
382
|
-
/* @__PURE__ */
|
|
424
|
+
/* @__PURE__ */ jsx2("div", { className: "cnfy-toolbar-divider" }),
|
|
425
|
+
/* @__PURE__ */ jsx2(
|
|
383
426
|
ToolbarButton,
|
|
384
427
|
{
|
|
385
428
|
onClick: () => editor.chain().focus().undo().run(),
|
|
386
429
|
disabled: !editor.can().undo(),
|
|
387
430
|
title: "Undo",
|
|
388
|
-
children: /* @__PURE__ */
|
|
431
|
+
children: /* @__PURE__ */ jsx2(Undo, { size: 18 })
|
|
389
432
|
}
|
|
390
433
|
),
|
|
391
|
-
/* @__PURE__ */
|
|
434
|
+
/* @__PURE__ */ jsx2(
|
|
392
435
|
ToolbarButton,
|
|
393
436
|
{
|
|
394
437
|
onClick: () => editor.chain().focus().redo().run(),
|
|
395
438
|
disabled: !editor.can().redo(),
|
|
396
439
|
title: "Redo",
|
|
397
|
-
children: /* @__PURE__ */
|
|
440
|
+
children: /* @__PURE__ */ jsx2(Redo, { size: 18 })
|
|
398
441
|
}
|
|
399
442
|
)
|
|
400
443
|
] }),
|
|
401
|
-
/* @__PURE__ */
|
|
444
|
+
/* @__PURE__ */ jsx2(EditorContent, { editor, className: "cnfy-editor-content" })
|
|
402
445
|
] });
|
|
403
446
|
}
|
|
404
447
|
function ToolbarButton({
|
|
@@ -408,7 +451,7 @@ function ToolbarButton({
|
|
|
408
451
|
title,
|
|
409
452
|
children
|
|
410
453
|
}) {
|
|
411
|
-
return /* @__PURE__ */
|
|
454
|
+
return /* @__PURE__ */ jsx2(
|
|
412
455
|
"button",
|
|
413
456
|
{
|
|
414
457
|
onClick,
|
|
@@ -439,7 +482,7 @@ function useTheme() {
|
|
|
439
482
|
}
|
|
440
483
|
|
|
441
484
|
// components/chatbot/EditModal.tsx
|
|
442
|
-
import { jsx as
|
|
485
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
443
486
|
function EditModal({
|
|
444
487
|
isOpen,
|
|
445
488
|
initialContent,
|
|
@@ -498,30 +541,30 @@ function EditModal({
|
|
|
498
541
|
}
|
|
499
542
|
};
|
|
500
543
|
if (!isOpen) return null;
|
|
501
|
-
return /* @__PURE__ */
|
|
502
|
-
/* @__PURE__ */
|
|
544
|
+
return /* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-overlay", children: [
|
|
545
|
+
/* @__PURE__ */ jsx3(
|
|
503
546
|
"div",
|
|
504
547
|
{
|
|
505
548
|
className: "cnfy-edit-modal-backdrop",
|
|
506
549
|
onClick: onClose
|
|
507
550
|
}
|
|
508
551
|
),
|
|
509
|
-
/* @__PURE__ */
|
|
510
|
-
/* @__PURE__ */
|
|
511
|
-
/* @__PURE__ */
|
|
512
|
-
/* @__PURE__ */
|
|
552
|
+
/* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal", children: [
|
|
553
|
+
/* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-header", children: [
|
|
554
|
+
/* @__PURE__ */ jsx3("h2", { className: "cnfy-edit-modal-title", children: "Edit Article" }),
|
|
555
|
+
/* @__PURE__ */ jsx3(
|
|
513
556
|
"button",
|
|
514
557
|
{
|
|
515
558
|
onClick: onClose,
|
|
516
559
|
className: "cnfy-edit-modal-close-btn",
|
|
517
|
-
children: /* @__PURE__ */
|
|
560
|
+
children: /* @__PURE__ */ jsx3(X, { size: 20, className: "cnfy-edit-modal-close-icon" })
|
|
518
561
|
}
|
|
519
562
|
)
|
|
520
563
|
] }),
|
|
521
|
-
/* @__PURE__ */
|
|
522
|
-
/* @__PURE__ */
|
|
523
|
-
/* @__PURE__ */
|
|
524
|
-
/* @__PURE__ */
|
|
564
|
+
/* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-body", children: [
|
|
565
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
566
|
+
/* @__PURE__ */ jsx3("label", { className: "cnfy-edit-label", children: "Article Content" }),
|
|
567
|
+
/* @__PURE__ */ jsx3(
|
|
525
568
|
RichTextEditor,
|
|
526
569
|
{
|
|
527
570
|
content,
|
|
@@ -530,29 +573,29 @@ function EditModal({
|
|
|
530
573
|
}
|
|
531
574
|
)
|
|
532
575
|
] }),
|
|
533
|
-
/* @__PURE__ */
|
|
534
|
-
/* @__PURE__ */
|
|
535
|
-
/* @__PURE__ */
|
|
576
|
+
/* @__PURE__ */ jsxs2("div", { children: [
|
|
577
|
+
/* @__PURE__ */ jsx3("label", { className: "cnfy-edit-label", children: "Meta Keywords" }),
|
|
578
|
+
/* @__PURE__ */ jsx3("div", { className: "cnfy-keyword-list", children: keywords.map((keyword, index) => /* @__PURE__ */ jsxs2(
|
|
536
579
|
"span",
|
|
537
580
|
{
|
|
538
581
|
className: "cnfy-keyword-tag",
|
|
539
582
|
children: [
|
|
540
583
|
"#",
|
|
541
584
|
keyword,
|
|
542
|
-
/* @__PURE__ */
|
|
585
|
+
/* @__PURE__ */ jsx3(
|
|
543
586
|
"button",
|
|
544
587
|
{
|
|
545
588
|
onClick: () => handleRemoveKeyword(index),
|
|
546
589
|
className: "cnfy-keyword-remove-btn",
|
|
547
|
-
children: /* @__PURE__ */
|
|
590
|
+
children: /* @__PURE__ */ jsx3(X, { size: 14 })
|
|
548
591
|
}
|
|
549
592
|
)
|
|
550
593
|
]
|
|
551
594
|
},
|
|
552
595
|
index
|
|
553
596
|
)) }),
|
|
554
|
-
/* @__PURE__ */
|
|
555
|
-
/* @__PURE__ */
|
|
597
|
+
/* @__PURE__ */ jsxs2("div", { className: "cnfy-keyword-input-row", children: [
|
|
598
|
+
/* @__PURE__ */ jsx3(
|
|
556
599
|
"input",
|
|
557
600
|
{
|
|
558
601
|
type: "text",
|
|
@@ -563,7 +606,7 @@ function EditModal({
|
|
|
563
606
|
className: "cnfy-keyword-input"
|
|
564
607
|
}
|
|
565
608
|
),
|
|
566
|
-
/* @__PURE__ */
|
|
609
|
+
/* @__PURE__ */ jsx3(
|
|
567
610
|
"button",
|
|
568
611
|
{
|
|
569
612
|
onClick: handleAddKeyword,
|
|
@@ -574,8 +617,8 @@ function EditModal({
|
|
|
574
617
|
] })
|
|
575
618
|
] })
|
|
576
619
|
] }),
|
|
577
|
-
/* @__PURE__ */
|
|
578
|
-
/* @__PURE__ */
|
|
620
|
+
/* @__PURE__ */ jsxs2("div", { className: "cnfy-edit-modal-footer", children: [
|
|
621
|
+
/* @__PURE__ */ jsx3(
|
|
579
622
|
"button",
|
|
580
623
|
{
|
|
581
624
|
onClick: onClose,
|
|
@@ -583,7 +626,7 @@ function EditModal({
|
|
|
583
626
|
children: "Cancel"
|
|
584
627
|
}
|
|
585
628
|
),
|
|
586
|
-
/* @__PURE__ */
|
|
629
|
+
/* @__PURE__ */ jsx3(
|
|
587
630
|
"button",
|
|
588
631
|
{
|
|
589
632
|
onClick: () => onSaveDraft(content, keywords),
|
|
@@ -591,7 +634,7 @@ function EditModal({
|
|
|
591
634
|
children: "Save Draft"
|
|
592
635
|
}
|
|
593
636
|
),
|
|
594
|
-
/* @__PURE__ */
|
|
637
|
+
/* @__PURE__ */ jsx3(
|
|
595
638
|
"button",
|
|
596
639
|
{
|
|
597
640
|
onClick: () => onPost(content, keywords),
|
|
@@ -608,7 +651,7 @@ function EditModal({
|
|
|
608
651
|
// components/news/NewsList.tsx
|
|
609
652
|
import { useState as useState3 } from "react";
|
|
610
653
|
import { Eye, RefreshCcw } from "lucide-react";
|
|
611
|
-
import { jsx as
|
|
654
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
612
655
|
var dateFormatter = new Intl.DateTimeFormat("en-GB", {
|
|
613
656
|
day: "2-digit",
|
|
614
657
|
month: "short",
|
|
@@ -650,19 +693,19 @@ function NewsList({
|
|
|
650
693
|
b = Math.round(b + (255 - b) * (percent / 100));
|
|
651
694
|
return `rgb(${r}, ${g}, ${b})`;
|
|
652
695
|
};
|
|
653
|
-
return /* @__PURE__ */
|
|
696
|
+
return /* @__PURE__ */ jsx4("div", { className: "cnfy-news-list", children: news.flatMap((item) => {
|
|
654
697
|
const publishedDate = new Date(item.publishedAt);
|
|
655
698
|
const links = extractLinksFromContent(item.content);
|
|
656
699
|
if (links.length > 0) {
|
|
657
|
-
return links.map((link, idx) => /* @__PURE__ */
|
|
700
|
+
return links.map((link, idx) => /* @__PURE__ */ jsxs3(
|
|
658
701
|
"div",
|
|
659
702
|
{
|
|
660
703
|
className: "cnfy-news-card",
|
|
661
704
|
children: [
|
|
662
|
-
/* @__PURE__ */
|
|
663
|
-
/* @__PURE__ */
|
|
664
|
-
/* @__PURE__ */
|
|
665
|
-
/* @__PURE__ */
|
|
705
|
+
/* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-content", children: [
|
|
706
|
+
/* @__PURE__ */ jsx4("p", { className: "cnfy-news-card-title", children: link.title }),
|
|
707
|
+
/* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-meta", children: [
|
|
708
|
+
/* @__PURE__ */ jsx4(
|
|
666
709
|
"span",
|
|
667
710
|
{
|
|
668
711
|
className: "cnfy-news-badge",
|
|
@@ -674,27 +717,27 @@ function NewsList({
|
|
|
674
717
|
children: link.source || item.sourceName
|
|
675
718
|
}
|
|
676
719
|
),
|
|
677
|
-
/* @__PURE__ */
|
|
678
|
-
/* @__PURE__ */
|
|
679
|
-
/* @__PURE__ */
|
|
680
|
-
/* @__PURE__ */
|
|
720
|
+
/* @__PURE__ */ jsx4("span", { children: "\u2022" }),
|
|
721
|
+
/* @__PURE__ */ jsx4("span", { className: "cnfy-news-card-category", children: item.category }),
|
|
722
|
+
/* @__PURE__ */ jsx4("span", { children: "\u2022" }),
|
|
723
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
681
724
|
dateFormatter.format(publishedDate),
|
|
682
725
|
" ",
|
|
683
726
|
timeFormatter.format(publishedDate)
|
|
684
727
|
] })
|
|
685
728
|
] })
|
|
686
729
|
] }),
|
|
687
|
-
/* @__PURE__ */
|
|
688
|
-
/* @__PURE__ */
|
|
730
|
+
/* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-actions", children: [
|
|
731
|
+
/* @__PURE__ */ jsx4(
|
|
689
732
|
"button",
|
|
690
733
|
{
|
|
691
734
|
onClick: () => window.open(link.url, "_blank"),
|
|
692
735
|
className: "cnfy-news-action-btn",
|
|
693
736
|
title: "View",
|
|
694
|
-
children: /* @__PURE__ */
|
|
737
|
+
children: /* @__PURE__ */ jsx4(Eye, { size: 16 })
|
|
695
738
|
}
|
|
696
739
|
),
|
|
697
|
-
/* @__PURE__ */
|
|
740
|
+
/* @__PURE__ */ jsx4(
|
|
698
741
|
"button",
|
|
699
742
|
{
|
|
700
743
|
onClick: () => onRecreate({
|
|
@@ -704,7 +747,7 @@ function NewsList({
|
|
|
704
747
|
}),
|
|
705
748
|
className: "cnfy-news-action-btn",
|
|
706
749
|
title: "Recreate",
|
|
707
|
-
children: /* @__PURE__ */
|
|
750
|
+
children: /* @__PURE__ */ jsx4(RefreshCcw, { size: 16 })
|
|
708
751
|
}
|
|
709
752
|
)
|
|
710
753
|
] })
|
|
@@ -713,15 +756,15 @@ function NewsList({
|
|
|
713
756
|
`${item._id}-link-${idx}`
|
|
714
757
|
));
|
|
715
758
|
}
|
|
716
|
-
return /* @__PURE__ */
|
|
759
|
+
return /* @__PURE__ */ jsxs3(
|
|
717
760
|
"div",
|
|
718
761
|
{
|
|
719
762
|
className: "cnfy-news-card",
|
|
720
763
|
children: [
|
|
721
|
-
/* @__PURE__ */
|
|
722
|
-
/* @__PURE__ */
|
|
723
|
-
/* @__PURE__ */
|
|
724
|
-
/* @__PURE__ */
|
|
764
|
+
/* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-content", children: [
|
|
765
|
+
/* @__PURE__ */ jsx4("p", { className: "cnfy-news-card-title", children: item.title }),
|
|
766
|
+
/* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-meta", children: [
|
|
767
|
+
/* @__PURE__ */ jsx4(
|
|
725
768
|
"span",
|
|
726
769
|
{
|
|
727
770
|
className: "cnfy-news-badge",
|
|
@@ -733,27 +776,27 @@ function NewsList({
|
|
|
733
776
|
children: item.sourceName
|
|
734
777
|
}
|
|
735
778
|
),
|
|
736
|
-
/* @__PURE__ */
|
|
737
|
-
/* @__PURE__ */
|
|
738
|
-
/* @__PURE__ */
|
|
739
|
-
/* @__PURE__ */
|
|
779
|
+
/* @__PURE__ */ jsx4("span", { children: "\u2022" }),
|
|
780
|
+
/* @__PURE__ */ jsx4("span", { className: "cnfy-news-card-category", children: item.category }),
|
|
781
|
+
/* @__PURE__ */ jsx4("span", { children: "\u2022" }),
|
|
782
|
+
/* @__PURE__ */ jsxs3("span", { children: [
|
|
740
783
|
dateFormatter.format(publishedDate),
|
|
741
784
|
" ",
|
|
742
785
|
timeFormatter.format(publishedDate)
|
|
743
786
|
] })
|
|
744
787
|
] })
|
|
745
788
|
] }),
|
|
746
|
-
/* @__PURE__ */
|
|
747
|
-
/* @__PURE__ */
|
|
789
|
+
/* @__PURE__ */ jsxs3("div", { className: "cnfy-news-card-actions", children: [
|
|
790
|
+
/* @__PURE__ */ jsx4(
|
|
748
791
|
"button",
|
|
749
792
|
{
|
|
750
793
|
onClick: () => onView(item),
|
|
751
794
|
className: "cnfy-news-action-btn",
|
|
752
795
|
title: "View",
|
|
753
|
-
children: /* @__PURE__ */
|
|
796
|
+
children: /* @__PURE__ */ jsx4(Eye, { size: 16 })
|
|
754
797
|
}
|
|
755
798
|
),
|
|
756
|
-
/* @__PURE__ */
|
|
799
|
+
/* @__PURE__ */ jsx4(
|
|
757
800
|
"button",
|
|
758
801
|
{
|
|
759
802
|
onClick: () => onRecreate({
|
|
@@ -763,7 +806,7 @@ function NewsList({
|
|
|
763
806
|
}),
|
|
764
807
|
className: "cnfy-news-action-btn",
|
|
765
808
|
title: "Recreate",
|
|
766
|
-
children: /* @__PURE__ */
|
|
809
|
+
children: /* @__PURE__ */ jsx4(RefreshCcw, { size: 16 })
|
|
767
810
|
}
|
|
768
811
|
)
|
|
769
812
|
] })
|
|
@@ -794,7 +837,7 @@ var getNewsBySource = async (sourceId) => {
|
|
|
794
837
|
|
|
795
838
|
// components/chatbot/ChatWindow.tsx
|
|
796
839
|
import Select from "react-select";
|
|
797
|
-
import { jsx as
|
|
840
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
798
841
|
var ACTION_ICONS = {
|
|
799
842
|
recreate_article: RefreshCcw2,
|
|
800
843
|
create_summary: ListChecks,
|
|
@@ -809,7 +852,8 @@ function ChatWindow({
|
|
|
809
852
|
onSelectNews,
|
|
810
853
|
isStreaming = false,
|
|
811
854
|
analyzedData,
|
|
812
|
-
onSelectAction
|
|
855
|
+
onSelectAction,
|
|
856
|
+
onPost: onPostCallback
|
|
813
857
|
}) {
|
|
814
858
|
var _a, _b;
|
|
815
859
|
const { loading, showNewsPanel } = useTheme();
|
|
@@ -858,7 +902,7 @@ function ChatWindow({
|
|
|
858
902
|
handleCloseModal();
|
|
859
903
|
};
|
|
860
904
|
const handlePost = (content, keywords) => {
|
|
861
|
-
|
|
905
|
+
onPostCallback == null ? void 0 : onPostCallback(content, keywords);
|
|
862
906
|
handleCloseModal();
|
|
863
907
|
};
|
|
864
908
|
useLayoutEffect(() => {
|
|
@@ -970,13 +1014,13 @@ function ChatWindow({
|
|
|
970
1014
|
});
|
|
971
1015
|
return { blocks, metaKeywords };
|
|
972
1016
|
}
|
|
973
|
-
return /* @__PURE__ */
|
|
974
|
-
/* @__PURE__ */
|
|
1017
|
+
return /* @__PURE__ */ jsxs4("div", { className: "cnfy-chat", children: [
|
|
1018
|
+
/* @__PURE__ */ jsx5("div", { className: "cnfy-chat-area", children: /* @__PURE__ */ jsxs4("div", { className: "cnfy-chat-scroll", children: [
|
|
975
1019
|
messages.map((msg) => {
|
|
976
1020
|
var _a2;
|
|
977
1021
|
const parsed = formatAIContent(msg.content);
|
|
978
|
-
return /* @__PURE__ */
|
|
979
|
-
/* @__PURE__ */
|
|
1022
|
+
return /* @__PURE__ */ jsxs4("div", { className: "cnfy-msg", children: [
|
|
1023
|
+
/* @__PURE__ */ jsx5("div", { className: "cnfy-msg-avatar-wrap", children: /* @__PURE__ */ jsx5(
|
|
980
1024
|
"div",
|
|
981
1025
|
{
|
|
982
1026
|
className: "cnfy-msg-avatar",
|
|
@@ -986,19 +1030,19 @@ function ChatWindow({
|
|
|
986
1030
|
children: msg.role === "assistant" ? "AI" : "You"
|
|
987
1031
|
}
|
|
988
1032
|
) }),
|
|
989
|
-
/* @__PURE__ */
|
|
990
|
-
msg.role === "assistant" && parsed.blocks.length > 0 && /* @__PURE__ */
|
|
1033
|
+
/* @__PURE__ */ jsxs4("div", { className: "cnfy-msg-body", children: [
|
|
1034
|
+
msg.role === "assistant" && parsed.blocks.length > 0 && /* @__PURE__ */ jsx5("div", { className: "cnfy-msg-copy-row", children: /* @__PURE__ */ jsx5(
|
|
991
1035
|
"button",
|
|
992
1036
|
{
|
|
993
1037
|
onClick: () => handleCopy(parsed.blocks, msg.id),
|
|
994
1038
|
className: "cnfy-copy-btn",
|
|
995
1039
|
title: "Copy to clipboard",
|
|
996
|
-
children: copiedId === msg.id ? /* @__PURE__ */
|
|
1040
|
+
children: copiedId === msg.id ? /* @__PURE__ */ jsx5(Check, { size: 16, className: "cnfy-copy-icon--copied" }) : /* @__PURE__ */ jsx5(Copy, { size: 16 })
|
|
997
1041
|
}
|
|
998
1042
|
) }),
|
|
999
1043
|
parsed.blocks.map((block, idx) => {
|
|
1000
1044
|
if (block.type === "h1") {
|
|
1001
|
-
return /* @__PURE__ */
|
|
1045
|
+
return /* @__PURE__ */ jsx5(
|
|
1002
1046
|
"h1",
|
|
1003
1047
|
{
|
|
1004
1048
|
className: "cnfy-block-h1",
|
|
@@ -1008,7 +1052,7 @@ function ChatWindow({
|
|
|
1008
1052
|
);
|
|
1009
1053
|
}
|
|
1010
1054
|
if (block.type === "h2") {
|
|
1011
|
-
return /* @__PURE__ */
|
|
1055
|
+
return /* @__PURE__ */ jsx5(
|
|
1012
1056
|
"h2",
|
|
1013
1057
|
{
|
|
1014
1058
|
className: "cnfy-block-h2",
|
|
@@ -1017,9 +1061,9 @@ function ChatWindow({
|
|
|
1017
1061
|
idx
|
|
1018
1062
|
);
|
|
1019
1063
|
}
|
|
1020
|
-
return /* @__PURE__ */
|
|
1064
|
+
return /* @__PURE__ */ jsx5("p", { className: "cnfy-block-p", children: block.text }, idx);
|
|
1021
1065
|
}),
|
|
1022
|
-
parsed.metaKeywords.length > 0 && /* @__PURE__ */
|
|
1066
|
+
parsed.metaKeywords.length > 0 && /* @__PURE__ */ jsx5("div", { className: "cnfy-msg-keywords", children: /* @__PURE__ */ jsx5("div", { className: "cnfy-msg-keywords-list", children: parsed.metaKeywords.map((tag, i) => /* @__PURE__ */ jsxs4(
|
|
1023
1067
|
"span",
|
|
1024
1068
|
{
|
|
1025
1069
|
className: "cnfy-msg-keyword-tag",
|
|
@@ -1030,41 +1074,41 @@ function ChatWindow({
|
|
|
1030
1074
|
},
|
|
1031
1075
|
i
|
|
1032
1076
|
)) }) }),
|
|
1033
|
-
msg.role === "assistant" && (analyzedData == null ? void 0 : analyzedData.messageId) === msg.id && analyzedData.options.length > 0 && /* @__PURE__ */
|
|
1077
|
+
msg.role === "assistant" && (analyzedData == null ? void 0 : analyzedData.messageId) === msg.id && analyzedData.options.length > 0 && /* @__PURE__ */ jsx5("div", { className: "cnfy-action-options", children: analyzedData.options.map((option) => {
|
|
1034
1078
|
const IconComponent = ACTION_ICONS[option.id] || FileText;
|
|
1035
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ jsxs4(
|
|
1036
1080
|
"button",
|
|
1037
1081
|
{
|
|
1038
1082
|
onClick: () => onSelectAction == null ? void 0 : onSelectAction(option.id, analyzedData.url, analyzedData.content),
|
|
1039
1083
|
className: "cnfy-action-btn",
|
|
1040
1084
|
children: [
|
|
1041
|
-
/* @__PURE__ */
|
|
1085
|
+
/* @__PURE__ */ jsx5(IconComponent, { size: 16 }),
|
|
1042
1086
|
option.name
|
|
1043
1087
|
]
|
|
1044
1088
|
},
|
|
1045
1089
|
option.id
|
|
1046
1090
|
);
|
|
1047
1091
|
}) }),
|
|
1048
|
-
msg.role === "assistant" && parsed.blocks.length > 0 && !(analyzedData == null ? void 0 : analyzedData.messageId) && (!isStreaming || msg.id !== ((_a2 = messages[messages.length - 1]) == null ? void 0 : _a2.id)) && /* @__PURE__ */
|
|
1049
|
-
/* @__PURE__ */
|
|
1092
|
+
msg.role === "assistant" && parsed.blocks.length > 0 && !(analyzedData == null ? void 0 : analyzedData.messageId) && (!isStreaming || msg.id !== ((_a2 = messages[messages.length - 1]) == null ? void 0 : _a2.id)) && /* @__PURE__ */ jsxs4("div", { className: "cnfy-msg-actions", children: [
|
|
1093
|
+
/* @__PURE__ */ jsxs4(
|
|
1050
1094
|
"button",
|
|
1051
1095
|
{
|
|
1052
1096
|
onClick: () => handleEdit(parsed.blocks, parsed.metaKeywords, msg.id),
|
|
1053
1097
|
className: "cnfy-btn-edit",
|
|
1054
1098
|
children: [
|
|
1055
|
-
/* @__PURE__ */
|
|
1099
|
+
/* @__PURE__ */ jsx5(Edit3, { size: 16 }),
|
|
1056
1100
|
"Edit"
|
|
1057
1101
|
]
|
|
1058
1102
|
}
|
|
1059
1103
|
),
|
|
1060
|
-
/* @__PURE__ */
|
|
1104
|
+
/* @__PURE__ */ jsxs4(
|
|
1061
1105
|
"button",
|
|
1062
1106
|
{
|
|
1063
1107
|
onClick: () => handlePost(msg.content, parsed.metaKeywords),
|
|
1064
1108
|
className: "cnfy-btn-post",
|
|
1065
1109
|
style: { backgroundColor: primaryColor, color: "#fff" },
|
|
1066
1110
|
children: [
|
|
1067
|
-
/* @__PURE__ */
|
|
1111
|
+
/* @__PURE__ */ jsx5(Send, { size: 16 }),
|
|
1068
1112
|
"Post"
|
|
1069
1113
|
]
|
|
1070
1114
|
}
|
|
@@ -1073,34 +1117,34 @@ function ChatWindow({
|
|
|
1073
1117
|
] })
|
|
1074
1118
|
] }, msg.id);
|
|
1075
1119
|
}),
|
|
1076
|
-
/* @__PURE__ */
|
|
1120
|
+
/* @__PURE__ */ jsx5("div", { ref: bottomRef })
|
|
1077
1121
|
] }) }),
|
|
1078
|
-
/* @__PURE__ */
|
|
1079
|
-
|
|
1080
|
-
/* @__PURE__ */
|
|
1122
|
+
/* @__PURE__ */ jsx5("div", { className: "cnfy-input-area", children: /* @__PURE__ */ jsxs4("div", { className: "cnfy-input-inner", children: [
|
|
1123
|
+
/* @__PURE__ */ jsxs4("div", { ref: dropdownRef, className: "cnfy-news-pulse-wrap", children: [
|
|
1124
|
+
/* @__PURE__ */ jsx5(
|
|
1081
1125
|
"button",
|
|
1082
1126
|
{
|
|
1083
1127
|
onClick: handleOpenNewsDropdown,
|
|
1084
1128
|
className: "cnfy-news-pulse-btn cnfy-animate-pulse",
|
|
1085
1129
|
title: "Select from trending news",
|
|
1086
|
-
children: /* @__PURE__ */
|
|
1130
|
+
children: /* @__PURE__ */ jsx5(Zap, { size: 16 })
|
|
1087
1131
|
}
|
|
1088
1132
|
),
|
|
1089
|
-
showNewsDropdown && /* @__PURE__ */
|
|
1090
|
-
/* @__PURE__ */
|
|
1091
|
-
/* @__PURE__ */
|
|
1092
|
-
/* @__PURE__ */
|
|
1133
|
+
showNewsDropdown && /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown", children: [
|
|
1134
|
+
/* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown-header", style: { backgroundColor: primaryColor, color: "#fff" }, children: [
|
|
1135
|
+
/* @__PURE__ */ jsx5("span", { className: "cnfy-news-dropdown-title", children: "Select News" }),
|
|
1136
|
+
/* @__PURE__ */ jsx5(
|
|
1093
1137
|
"button",
|
|
1094
1138
|
{
|
|
1095
1139
|
onClick: () => setShowNewsDropdown(false),
|
|
1096
1140
|
className: "cnfy-news-dropdown-close",
|
|
1097
1141
|
style: { backgroundColor: primaryColor, color: "#fff" },
|
|
1098
|
-
children: /* @__PURE__ */
|
|
1142
|
+
children: /* @__PURE__ */ jsx5(X2, { size: 14 })
|
|
1099
1143
|
}
|
|
1100
1144
|
)
|
|
1101
1145
|
] }),
|
|
1102
|
-
/* @__PURE__ */
|
|
1103
|
-
/* @__PURE__ */
|
|
1146
|
+
/* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown-source", children: [
|
|
1147
|
+
/* @__PURE__ */ jsx5("div", { className: "cnfy-news-dropdown-select-wrap", children: /* @__PURE__ */ jsx5(
|
|
1104
1148
|
Select,
|
|
1105
1149
|
{
|
|
1106
1150
|
options: [
|
|
@@ -1146,7 +1190,7 @@ function ChatWindow({
|
|
|
1146
1190
|
}
|
|
1147
1191
|
}
|
|
1148
1192
|
) }),
|
|
1149
|
-
selectedSource && /* @__PURE__ */
|
|
1193
|
+
selectedSource && /* @__PURE__ */ jsxs4(
|
|
1150
1194
|
"button",
|
|
1151
1195
|
{
|
|
1152
1196
|
onClick: handleScrape,
|
|
@@ -1154,28 +1198,28 @@ function ChatWindow({
|
|
|
1154
1198
|
className: "cnfy-scrape-btn",
|
|
1155
1199
|
title: "Fetch latest news",
|
|
1156
1200
|
children: [
|
|
1157
|
-
/* @__PURE__ */
|
|
1201
|
+
/* @__PURE__ */ jsx5(RefreshCcw2, { size: 14, className: scraping ? "cnfy-animate-spin" : "" }),
|
|
1158
1202
|
scraping ? "Scraping..." : "Scrape"
|
|
1159
1203
|
]
|
|
1160
1204
|
}
|
|
1161
1205
|
),
|
|
1162
|
-
!selectedSource && /* @__PURE__ */
|
|
1206
|
+
!selectedSource && /* @__PURE__ */ jsxs4(
|
|
1163
1207
|
"button",
|
|
1164
1208
|
{
|
|
1165
1209
|
onClick: () => fetchNews(null),
|
|
1166
1210
|
disabled: loadingNews,
|
|
1167
1211
|
className: "cnfy-refresh-btn",
|
|
1168
1212
|
children: [
|
|
1169
|
-
/* @__PURE__ */
|
|
1213
|
+
/* @__PURE__ */ jsx5(RefreshCcw2, { size: 14, className: loadingNews ? "cnfy-animate-spin" : "" }),
|
|
1170
1214
|
"Refresh"
|
|
1171
1215
|
]
|
|
1172
1216
|
}
|
|
1173
1217
|
)
|
|
1174
1218
|
] }),
|
|
1175
|
-
/* @__PURE__ */
|
|
1176
|
-
/* @__PURE__ */
|
|
1177
|
-
selectedSource && /* @__PURE__ */
|
|
1178
|
-
] }) : /* @__PURE__ */
|
|
1219
|
+
/* @__PURE__ */ jsx5("div", { className: "cnfy-news-dropdown-list", children: loadingNews ? /* @__PURE__ */ jsx5("div", { className: "cnfy-news-dropdown-msg", children: "Loading news..." }) : trendingNews.length === 0 ? /* @__PURE__ */ jsxs4("div", { className: "cnfy-news-dropdown-msg", children: [
|
|
1220
|
+
/* @__PURE__ */ jsx5("p", { children: "No news found." }),
|
|
1221
|
+
selectedSource && /* @__PURE__ */ jsx5("p", { className: "cnfy-news-dropdown-hint", children: 'Click "Scrape" to fetch latest news.' })
|
|
1222
|
+
] }) : /* @__PURE__ */ jsx5(
|
|
1179
1223
|
NewsList,
|
|
1180
1224
|
{
|
|
1181
1225
|
news: trendingNews.slice(0, 10),
|
|
@@ -1188,7 +1232,7 @@ function ChatWindow({
|
|
|
1188
1232
|
) })
|
|
1189
1233
|
] })
|
|
1190
1234
|
] }),
|
|
1191
|
-
/* @__PURE__ */
|
|
1235
|
+
/* @__PURE__ */ jsx5(
|
|
1192
1236
|
"textarea",
|
|
1193
1237
|
{
|
|
1194
1238
|
ref: textareaRef,
|
|
@@ -1206,17 +1250,17 @@ function ChatWindow({
|
|
|
1206
1250
|
style: { maxHeight: "200px", overflowY: input.split("\n").length > 6 ? "auto" : "hidden" }
|
|
1207
1251
|
}
|
|
1208
1252
|
),
|
|
1209
|
-
/* @__PURE__ */
|
|
1253
|
+
/* @__PURE__ */ jsx5(
|
|
1210
1254
|
"button",
|
|
1211
1255
|
{
|
|
1212
1256
|
onClick: handleSend,
|
|
1213
1257
|
className: "cnfy-send-btn",
|
|
1214
1258
|
style: { backgroundColor: primaryColor, color: "#fff" },
|
|
1215
|
-
children: /* @__PURE__ */
|
|
1259
|
+
children: /* @__PURE__ */ jsx5(SendHorizontal, { size: 18 })
|
|
1216
1260
|
}
|
|
1217
1261
|
)
|
|
1218
1262
|
] }) }),
|
|
1219
|
-
/* @__PURE__ */
|
|
1263
|
+
/* @__PURE__ */ jsx5(
|
|
1220
1264
|
EditModal,
|
|
1221
1265
|
{
|
|
1222
1266
|
isOpen: editModal.isOpen,
|
|
@@ -1231,115 +1275,31 @@ function ChatWindow({
|
|
|
1231
1275
|
}
|
|
1232
1276
|
|
|
1233
1277
|
// components/chatbot/UserMenu.tsx
|
|
1234
|
-
import {
|
|
1235
|
-
import {
|
|
1236
|
-
Settings,
|
|
1237
|
-
User,
|
|
1238
|
-
HelpCircle,
|
|
1239
|
-
LogOut,
|
|
1240
|
-
Palette
|
|
1241
|
-
} from "lucide-react";
|
|
1242
|
-
import toast from "react-hot-toast";
|
|
1243
|
-
|
|
1244
|
-
// services/auth.service.ts
|
|
1245
|
-
var logoutUser = async () => {
|
|
1246
|
-
const { data } = await api_default.post("/auth/logout");
|
|
1247
|
-
return data;
|
|
1248
|
-
};
|
|
1249
|
-
|
|
1250
|
-
// components/chatbot/UserMenu.tsx
|
|
1251
|
-
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1278
|
+
import { Settings } from "lucide-react";
|
|
1279
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
1252
1280
|
function UserMenu({
|
|
1253
|
-
|
|
1254
|
-
onLogout
|
|
1255
|
-
}) {
|
|
1256
|
-
const [open, setOpen] = useState5(false);
|
|
1257
|
-
const ref = useRef2(null);
|
|
1258
|
-
useEffect5(() => {
|
|
1259
|
-
const handler = (e) => {
|
|
1260
|
-
if (ref.current && !ref.current.contains(e.target)) {
|
|
1261
|
-
setOpen(false);
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
|
-
document.addEventListener("mousedown", handler);
|
|
1265
|
-
return () => document.removeEventListener("mousedown", handler);
|
|
1266
|
-
}, []);
|
|
1267
|
-
function go(path) {
|
|
1268
|
-
setOpen(false);
|
|
1269
|
-
onNavigate == null ? void 0 : onNavigate(path);
|
|
1270
|
-
}
|
|
1271
|
-
async function logout() {
|
|
1272
|
-
setOpen(false);
|
|
1273
|
-
if (onLogout) {
|
|
1274
|
-
onLogout();
|
|
1275
|
-
return;
|
|
1276
|
-
}
|
|
1277
|
-
try {
|
|
1278
|
-
await logoutUser();
|
|
1279
|
-
toast.success("Logged out successfully");
|
|
1280
|
-
onNavigate == null ? void 0 : onNavigate("/login");
|
|
1281
|
-
} catch (err) {
|
|
1282
|
-
toast.error(err || "Logout failed");
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
return /* @__PURE__ */ jsxs6("div", { ref, className: "cnfy-user-menu", children: [
|
|
1286
|
-
/* @__PURE__ */ jsx7(
|
|
1287
|
-
"button",
|
|
1288
|
-
{
|
|
1289
|
-
onClick: () => setOpen((v) => !v),
|
|
1290
|
-
className: "cnfy-user-menu-trigger",
|
|
1291
|
-
"aria-label": "Settings",
|
|
1292
|
-
children: /* @__PURE__ */ jsx7(Settings, { size: 20, className: "cnfy-user-menu-trigger-icon" })
|
|
1293
|
-
}
|
|
1294
|
-
),
|
|
1295
|
-
open && /* @__PURE__ */ jsxs6("div", { className: "cnfy-dropdown", children: [
|
|
1296
|
-
/* @__PURE__ */ jsx7(MenuItem, { icon: User, label: "Account", onClick: () => go("/dashboard/account") }),
|
|
1297
|
-
/* @__PURE__ */ jsx7(MenuItem, { icon: Settings, label: "Preferences", onClick: () => go("/dashboard/preferences") }),
|
|
1298
|
-
/* @__PURE__ */ jsx7(MenuItem, { icon: Palette, label: "Appearance", onClick: () => go("/dashboard/appearance") }),
|
|
1299
|
-
/* @__PURE__ */ jsx7(MenuItem, { icon: HelpCircle, label: "Settings", onClick: () => go("/dashboard/settings") }),
|
|
1300
|
-
/* @__PURE__ */ jsx7(MenuItem, { icon: HelpCircle, label: "Help & Support", onClick: () => go("/dashboard/help") }),
|
|
1301
|
-
/* @__PURE__ */ jsx7("div", { className: "cnfy-dropdown-divider" }),
|
|
1302
|
-
/* @__PURE__ */ jsx7(
|
|
1303
|
-
MenuItem,
|
|
1304
|
-
{
|
|
1305
|
-
icon: LogOut,
|
|
1306
|
-
label: "Logout",
|
|
1307
|
-
danger: true,
|
|
1308
|
-
onClick: logout
|
|
1309
|
-
}
|
|
1310
|
-
)
|
|
1311
|
-
] })
|
|
1312
|
-
] });
|
|
1313
|
-
}
|
|
1314
|
-
function MenuItem({
|
|
1315
|
-
icon: Icon,
|
|
1316
|
-
label,
|
|
1317
|
-
onClick,
|
|
1318
|
-
danger = false
|
|
1281
|
+
onOpenPreferences
|
|
1319
1282
|
}) {
|
|
1320
|
-
return /* @__PURE__ */
|
|
1283
|
+
return /* @__PURE__ */ jsx6("div", { className: "cnfy-user-menu", children: /* @__PURE__ */ jsx6(
|
|
1321
1284
|
"button",
|
|
1322
1285
|
{
|
|
1323
|
-
onClick,
|
|
1324
|
-
className:
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
label
|
|
1328
|
-
]
|
|
1286
|
+
onClick: () => onOpenPreferences == null ? void 0 : onOpenPreferences(),
|
|
1287
|
+
className: "cnfy-user-menu-trigger",
|
|
1288
|
+
"aria-label": "Settings",
|
|
1289
|
+
children: /* @__PURE__ */ jsx6(Settings, { size: 20, className: "cnfy-user-menu-trigger-icon" })
|
|
1329
1290
|
}
|
|
1330
|
-
);
|
|
1291
|
+
) });
|
|
1331
1292
|
}
|
|
1332
1293
|
|
|
1333
1294
|
// components/chatbot/headerBar.tsx
|
|
1334
|
-
import { jsx as
|
|
1295
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1335
1296
|
function HeaderBar({
|
|
1336
|
-
|
|
1337
|
-
onLogout
|
|
1297
|
+
onOpenPreferences
|
|
1338
1298
|
}) {
|
|
1339
1299
|
const { primaryColor, botName, logoUrl } = useTheme();
|
|
1340
|
-
return /* @__PURE__ */
|
|
1341
|
-
/* @__PURE__ */
|
|
1342
|
-
logoUrl ? /* @__PURE__ */
|
|
1300
|
+
return /* @__PURE__ */ jsx7("header", { className: "cnfy-header", children: /* @__PURE__ */ jsxs5("div", { className: "cnfy-header-inner", children: [
|
|
1301
|
+
/* @__PURE__ */ jsxs5("div", { className: "cnfy-header-left", children: [
|
|
1302
|
+
logoUrl ? /* @__PURE__ */ jsx7("img", { src: logoUrl, alt: "Logo", className: "cnfy-header-logo-img" }) : /* @__PURE__ */ jsx7(
|
|
1343
1303
|
"div",
|
|
1344
1304
|
{
|
|
1345
1305
|
className: "cnfy-header-logo-fallback",
|
|
@@ -1347,224 +1307,579 @@ function HeaderBar({
|
|
|
1347
1307
|
children: botName.charAt(0).toUpperCase()
|
|
1348
1308
|
}
|
|
1349
1309
|
),
|
|
1350
|
-
/* @__PURE__ */
|
|
1310
|
+
/* @__PURE__ */ jsx7("span", { className: "cnfy-header-brand", children: botName.toUpperCase() })
|
|
1351
1311
|
] }),
|
|
1352
|
-
/* @__PURE__ */
|
|
1312
|
+
/* @__PURE__ */ jsx7("div", { className: "cnfy-header-right", children: /* @__PURE__ */ jsx7(UserMenu, { onOpenPreferences }) })
|
|
1353
1313
|
] }) });
|
|
1354
1314
|
}
|
|
1355
1315
|
|
|
1356
|
-
// components/
|
|
1357
|
-
import { useEffect as
|
|
1358
|
-
import
|
|
1359
|
-
import { jsx as
|
|
1360
|
-
function
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
isLoading: externalLoading
|
|
1316
|
+
// components/ui/Drawer.tsx
|
|
1317
|
+
import { useEffect as useEffect5 } from "react";
|
|
1318
|
+
import { X as X3 } from "lucide-react";
|
|
1319
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
1320
|
+
function Drawer({
|
|
1321
|
+
open,
|
|
1322
|
+
onClose,
|
|
1323
|
+
title,
|
|
1324
|
+
children
|
|
1366
1325
|
}) {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
if (externalNews !== void 0) {
|
|
1373
|
-
return;
|
|
1374
|
-
}
|
|
1375
|
-
setLoading(true);
|
|
1376
|
-
try {
|
|
1377
|
-
let data;
|
|
1378
|
-
if (selectedSource) {
|
|
1379
|
-
data = await getNewsBySource(selectedSource);
|
|
1380
|
-
} else {
|
|
1381
|
-
data = await getTrendingNews();
|
|
1382
|
-
}
|
|
1383
|
-
setNews(data || []);
|
|
1384
|
-
} catch (e) {
|
|
1385
|
-
toast2.error("Failed to load news");
|
|
1386
|
-
} finally {
|
|
1387
|
-
setLoading(false);
|
|
1388
|
-
}
|
|
1389
|
-
}, [selectedSource, externalNews]);
|
|
1390
|
-
useEffect6(() => {
|
|
1391
|
-
fetchNews();
|
|
1392
|
-
}, [fetchNews, refreshKey]);
|
|
1393
|
-
function handleView(item) {
|
|
1394
|
-
window.open(item.sourceUrl || item.link, "_blank");
|
|
1395
|
-
}
|
|
1396
|
-
if (isLoading) {
|
|
1397
|
-
return /* @__PURE__ */ jsx9("div", { className: "cnfy-trending-msg", children: "Loading news..." });
|
|
1398
|
-
}
|
|
1399
|
-
if (!displayNews || displayNews.length === 0) {
|
|
1400
|
-
return /* @__PURE__ */ jsxs8("div", { className: "cnfy-trending-msg cnfy-trending-msg--center", children: [
|
|
1401
|
-
/* @__PURE__ */ jsx9("p", { children: "No news found for this source." }),
|
|
1402
|
-
/* @__PURE__ */ jsx9("p", { className: "cnfy-trending-hint", children: 'Click "Scrape" to fetch latest news.' })
|
|
1403
|
-
] });
|
|
1404
|
-
}
|
|
1405
|
-
return /* @__PURE__ */ jsx9(
|
|
1406
|
-
NewsList,
|
|
1407
|
-
{
|
|
1408
|
-
news: displayNews,
|
|
1409
|
-
onView: handleView,
|
|
1410
|
-
onRecreate
|
|
1326
|
+
useEffect5(() => {
|
|
1327
|
+
if (open) {
|
|
1328
|
+
document.body.style.overflow = "hidden";
|
|
1329
|
+
} else {
|
|
1330
|
+
document.body.style.overflow = "";
|
|
1411
1331
|
}
|
|
1412
|
-
|
|
1332
|
+
return () => {
|
|
1333
|
+
document.body.style.overflow = "";
|
|
1334
|
+
};
|
|
1335
|
+
}, [open]);
|
|
1336
|
+
if (!open) return null;
|
|
1337
|
+
return /* @__PURE__ */ jsxs6("div", { className: "cnfy-drawer-overlay", children: [
|
|
1338
|
+
/* @__PURE__ */ jsx8("div", { className: "cnfy-drawer-backdrop", onClick: onClose }),
|
|
1339
|
+
/* @__PURE__ */ jsxs6("div", { className: "cnfy-drawer-panel", children: [
|
|
1340
|
+
/* @__PURE__ */ jsxs6("div", { className: "cnfy-drawer-header", children: [
|
|
1341
|
+
title && /* @__PURE__ */ jsx8("h2", { className: "cnfy-drawer-title", children: title }),
|
|
1342
|
+
/* @__PURE__ */ jsx8("button", { onClick: onClose, className: "cnfy-drawer-close-btn", children: /* @__PURE__ */ jsx8(X3, { size: 20 }) })
|
|
1343
|
+
] }),
|
|
1344
|
+
/* @__PURE__ */ jsx8("div", { className: "cnfy-drawer-body", children })
|
|
1345
|
+
] })
|
|
1346
|
+
] });
|
|
1413
1347
|
}
|
|
1414
1348
|
|
|
1415
|
-
// components/
|
|
1416
|
-
import {
|
|
1417
|
-
import
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
const
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1349
|
+
// components/preferences/Preferences.tsx
|
|
1350
|
+
import { useState as useState6, useEffect as useEffect7 } from "react";
|
|
1351
|
+
import toast from "react-hot-toast";
|
|
1352
|
+
|
|
1353
|
+
// services/settings.service.ts
|
|
1354
|
+
var triggerScrape = async ({
|
|
1355
|
+
state,
|
|
1356
|
+
cities
|
|
1357
|
+
}) => {
|
|
1358
|
+
const { data } = await api_default.post("/scrape/trigger", {
|
|
1359
|
+
state,
|
|
1360
|
+
cities
|
|
1361
|
+
});
|
|
1362
|
+
return data;
|
|
1363
|
+
};
|
|
1364
|
+
var getScrapeStatus = async () => {
|
|
1365
|
+
const { data } = await api_default.get("/scrape/status");
|
|
1366
|
+
return data.data;
|
|
1367
|
+
};
|
|
1368
|
+
|
|
1369
|
+
// components/ClientSelect.tsx
|
|
1370
|
+
import { useEffect as useEffect6, useState as useState5 } from "react";
|
|
1371
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
1372
|
+
var ReactSelect = null;
|
|
1373
|
+
var ClientSelect = (props) => {
|
|
1374
|
+
const [mounted, setMounted] = useState5(false);
|
|
1375
|
+
useEffect6(() => {
|
|
1376
|
+
setMounted(true);
|
|
1377
|
+
import("react-select").then((mod) => {
|
|
1378
|
+
ReactSelect = mod.default;
|
|
1379
|
+
});
|
|
1380
|
+
}, []);
|
|
1381
|
+
if (!mounted || !ReactSelect) return null;
|
|
1382
|
+
return /* @__PURE__ */ jsx9(ReactSelect, __spreadValues({}, props));
|
|
1383
|
+
};
|
|
1384
|
+
var ClientSelect_default = ClientSelect;
|
|
1385
|
+
|
|
1386
|
+
// components/preferences/Preferences.tsx
|
|
1387
|
+
import { Fragment, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1388
|
+
var STATE_OPTIONS = [
|
|
1389
|
+
{ value: "Uttar Pradesh", label: "Uttar Pradesh" }
|
|
1390
|
+
];
|
|
1391
|
+
var CITY_OPTIONS = [
|
|
1392
|
+
"Agra",
|
|
1393
|
+
"Aligarh",
|
|
1394
|
+
"Ayodhya",
|
|
1395
|
+
"Bareilly",
|
|
1396
|
+
"Bijnor",
|
|
1397
|
+
"Bulandshahr",
|
|
1398
|
+
"Etawah",
|
|
1399
|
+
"Firozabad",
|
|
1400
|
+
"Ghaziabad",
|
|
1401
|
+
"Gorakhpur",
|
|
1402
|
+
"Jhansi",
|
|
1403
|
+
"Kanpur",
|
|
1404
|
+
"Lucknow",
|
|
1405
|
+
"Mathura",
|
|
1406
|
+
"Meerut",
|
|
1407
|
+
"Moradabad",
|
|
1408
|
+
"Muzaffarnagar",
|
|
1409
|
+
"Noida",
|
|
1410
|
+
"Prayagraj",
|
|
1411
|
+
"Rampur",
|
|
1412
|
+
"Saharanpur",
|
|
1413
|
+
"Sitapur",
|
|
1414
|
+
"Unnao",
|
|
1415
|
+
"Varanasi"
|
|
1416
|
+
].map((city) => ({ value: city, label: city }));
|
|
1417
|
+
var LANGUAGE_OPTIONS = [
|
|
1418
|
+
{ value: "en", label: "English" },
|
|
1419
|
+
{ value: "hi", label: "Hindi" }
|
|
1420
|
+
];
|
|
1421
|
+
var TONE_OPTIONS = [
|
|
1422
|
+
{ value: "formal", label: "Formal" },
|
|
1423
|
+
{ value: "casual", label: "Casual" },
|
|
1424
|
+
{ value: "engaging", label: "Engaging" },
|
|
1425
|
+
{ value: "professional", label: "Professional" }
|
|
1426
|
+
];
|
|
1427
|
+
var STYLE_OPTIONS = [
|
|
1428
|
+
{ value: "news", label: "News Article" },
|
|
1429
|
+
{ value: "blog", label: "Blog Post" },
|
|
1430
|
+
{ value: "editorial", label: "Editorial" },
|
|
1431
|
+
{ value: "summary", label: "Summary" }
|
|
1432
|
+
];
|
|
1433
|
+
var WORD_COUNT_OPTIONS = [
|
|
1434
|
+
{ value: "short", label: "Short (~300 words)" },
|
|
1435
|
+
{ value: "medium", label: "Medium (~600 words)" },
|
|
1436
|
+
{ value: "long", label: "Long (~1000+ words)" }
|
|
1437
|
+
];
|
|
1438
|
+
function PreferencesPage() {
|
|
1439
|
+
var _a, _b, _c;
|
|
1440
|
+
const { preferences, loading, refreshPreferences, updatePreferences } = usePreferences();
|
|
1441
|
+
const primaryColor = ((_a = preferences == null ? void 0 : preferences.chatbot) == null ? void 0 : _a.primaryColor) || "#10b981";
|
|
1442
|
+
const [botName, setBotName] = useState6("");
|
|
1443
|
+
const [logo, setLogo] = useState6(null);
|
|
1444
|
+
const [logoUrl, setLogoUrl] = useState6(null);
|
|
1445
|
+
const [state, setState] = useState6(null);
|
|
1446
|
+
const [cities, setCities] = useState6([]);
|
|
1447
|
+
const [language, setLanguage] = useState6(null);
|
|
1448
|
+
const [tone, setTone] = useState6(null);
|
|
1449
|
+
const [style, setStyle] = useState6(null);
|
|
1450
|
+
const [wordCount, setWordCount] = useState6(null);
|
|
1451
|
+
const [includeQuotes, setIncludeQuotes] = useState6(true);
|
|
1452
|
+
const [includeFAQ, setIncludeFAQ] = useState6(false);
|
|
1453
|
+
const [targetAudience, setTargetAudience] = useState6("");
|
|
1454
|
+
const [saving, setSaving] = useState6(false);
|
|
1455
|
+
const [success, setSuccess] = useState6(false);
|
|
1456
|
+
const [scraping, setScraping] = useState6(false);
|
|
1457
|
+
const [scrapeStatus, setScrapeStatus] = useState6(null);
|
|
1458
|
+
const [loadingStatus, setLoadingStatus] = useState6(true);
|
|
1459
|
+
const [originalValues, setOriginalValues] = useState6({
|
|
1460
|
+
botName: "",
|
|
1461
|
+
state: void 0,
|
|
1462
|
+
cities: [],
|
|
1463
|
+
language: void 0,
|
|
1464
|
+
tone: void 0,
|
|
1465
|
+
style: void 0,
|
|
1466
|
+
wordCount: void 0,
|
|
1467
|
+
includeQuotes: true,
|
|
1468
|
+
includeFAQ: false,
|
|
1469
|
+
targetAudience: ""
|
|
1470
|
+
});
|
|
1437
1471
|
useEffect7(() => {
|
|
1438
|
-
const
|
|
1472
|
+
const fetchScrapeStatus = async () => {
|
|
1439
1473
|
try {
|
|
1440
|
-
const data = await
|
|
1441
|
-
|
|
1442
|
-
} catch (
|
|
1443
|
-
|
|
1474
|
+
const data = await getScrapeStatus();
|
|
1475
|
+
setScrapeStatus(data);
|
|
1476
|
+
} catch (error) {
|
|
1477
|
+
console.log("Failed to fetch scrape status:", error);
|
|
1444
1478
|
} finally {
|
|
1445
|
-
|
|
1479
|
+
setLoadingStatus(false);
|
|
1446
1480
|
}
|
|
1447
1481
|
};
|
|
1448
|
-
|
|
1482
|
+
fetchScrapeStatus();
|
|
1449
1483
|
}, []);
|
|
1450
|
-
const
|
|
1451
|
-
|
|
1484
|
+
const handleScrape = async () => {
|
|
1485
|
+
var _a2, _b2;
|
|
1486
|
+
setScraping(true);
|
|
1452
1487
|
try {
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
}
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1488
|
+
await triggerScrape({
|
|
1489
|
+
state: (_a2 = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _a2.state,
|
|
1490
|
+
cities: (_b2 = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _b2.cities
|
|
1491
|
+
});
|
|
1492
|
+
toast.success("News scraping started successfully!");
|
|
1493
|
+
setTimeout(async () => {
|
|
1494
|
+
try {
|
|
1495
|
+
const data = await getScrapeStatus();
|
|
1496
|
+
setScrapeStatus(data);
|
|
1497
|
+
} catch (e) {
|
|
1498
|
+
console.log("Failed to refresh scrape status:", e);
|
|
1499
|
+
}
|
|
1500
|
+
}, 2e3);
|
|
1501
|
+
} catch (error) {
|
|
1502
|
+
console.error(error);
|
|
1503
|
+
toast.error("Failed to trigger news scraping");
|
|
1462
1504
|
} finally {
|
|
1463
|
-
|
|
1505
|
+
setScraping(false);
|
|
1464
1506
|
}
|
|
1465
|
-
}, []);
|
|
1466
|
-
useEffect7(() => {
|
|
1467
|
-
fetchNews(selectedSource);
|
|
1468
|
-
}, [selectedSource, fetchNews]);
|
|
1469
|
-
const handleSourceSelect = (option) => {
|
|
1470
|
-
var _a;
|
|
1471
|
-
const value = (option == null ? void 0 : option.value) === ALL_SOURCES_VALUE ? null : (_a = option == null ? void 0 : option.value) != null ? _a : null;
|
|
1472
|
-
onSourceChange(value);
|
|
1473
1507
|
};
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1508
|
+
useEffect7(() => {
|
|
1509
|
+
var _a2, _b2, _c2, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
1510
|
+
if (preferences) {
|
|
1511
|
+
const name = ((_a2 = preferences.chatbot) == null ? void 0 : _a2.name) || "";
|
|
1512
|
+
const pState = (_b2 = preferences.localization) == null ? void 0 : _b2.state;
|
|
1513
|
+
const pCities = ((_c2 = preferences.localization) == null ? void 0 : _c2.cities) || [];
|
|
1514
|
+
const pLanguage = (_d = preferences.localization) == null ? void 0 : _d.language;
|
|
1515
|
+
setBotName(name);
|
|
1516
|
+
if ((_e = preferences.chatbot) == null ? void 0 : _e.logoUrl) setLogoUrl(preferences.chatbot.logoUrl);
|
|
1517
|
+
if (pState) {
|
|
1518
|
+
setState({ value: pState, label: pState });
|
|
1519
|
+
}
|
|
1520
|
+
if (Array.isArray(pCities)) {
|
|
1521
|
+
setCities(pCities.map((city) => ({ value: city, label: city })));
|
|
1522
|
+
}
|
|
1523
|
+
if (pLanguage) {
|
|
1524
|
+
const langOption = LANGUAGE_OPTIONS.find((opt) => opt.value === pLanguage);
|
|
1525
|
+
setLanguage(langOption || null);
|
|
1526
|
+
}
|
|
1527
|
+
const pTone = (_f = preferences.content) == null ? void 0 : _f.tone;
|
|
1528
|
+
const pStyle = (_g = preferences.content) == null ? void 0 : _g.style;
|
|
1529
|
+
const pWordCount = (_h = preferences.content) == null ? void 0 : _h.wordCount;
|
|
1530
|
+
const pIncludeQuotes = (_j = (_i = preferences.content) == null ? void 0 : _i.includeQuotes) != null ? _j : true;
|
|
1531
|
+
const pIncludeFAQ = (_l = (_k = preferences.content) == null ? void 0 : _k.includeFAQ) != null ? _l : false;
|
|
1532
|
+
const pTargetAudience = ((_m = preferences.content) == null ? void 0 : _m.targetAudience) || "";
|
|
1533
|
+
if (pTone) {
|
|
1534
|
+
const toneOption = TONE_OPTIONS.find((opt) => opt.value === pTone);
|
|
1535
|
+
setTone(toneOption || null);
|
|
1536
|
+
}
|
|
1537
|
+
if (pStyle) {
|
|
1538
|
+
const styleOption = STYLE_OPTIONS.find((opt) => opt.value === pStyle);
|
|
1539
|
+
setStyle(styleOption || null);
|
|
1540
|
+
}
|
|
1541
|
+
if (pWordCount) {
|
|
1542
|
+
const wordCountOption = WORD_COUNT_OPTIONS.find((opt) => opt.value === pWordCount);
|
|
1543
|
+
setWordCount(wordCountOption || null);
|
|
1544
|
+
}
|
|
1545
|
+
setIncludeQuotes(pIncludeQuotes);
|
|
1546
|
+
setIncludeFAQ(pIncludeFAQ);
|
|
1547
|
+
setTargetAudience(pTargetAudience);
|
|
1548
|
+
setOriginalValues({
|
|
1549
|
+
botName: name,
|
|
1550
|
+
state: pState,
|
|
1551
|
+
cities: pCities,
|
|
1552
|
+
language: pLanguage,
|
|
1553
|
+
tone: pTone,
|
|
1554
|
+
style: pStyle,
|
|
1555
|
+
wordCount: pWordCount,
|
|
1556
|
+
includeQuotes: pIncludeQuotes,
|
|
1557
|
+
includeFAQ: pIncludeFAQ,
|
|
1558
|
+
targetAudience: pTargetAudience
|
|
1559
|
+
});
|
|
1560
|
+
}
|
|
1561
|
+
}, [preferences]);
|
|
1562
|
+
const handleSave = async () => {
|
|
1563
|
+
if (!botName) {
|
|
1564
|
+
toast.error("Chatbot name is required");
|
|
1477
1565
|
return;
|
|
1478
1566
|
}
|
|
1479
|
-
|
|
1567
|
+
setSaving(true);
|
|
1568
|
+
setSuccess(false);
|
|
1480
1569
|
try {
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1570
|
+
const payload = {};
|
|
1571
|
+
if (botName !== originalValues.botName) {
|
|
1572
|
+
payload.botName = botName;
|
|
1573
|
+
}
|
|
1574
|
+
if (logo) {
|
|
1575
|
+
payload.logo = logo;
|
|
1576
|
+
}
|
|
1577
|
+
const currentState = state == null ? void 0 : state.value;
|
|
1578
|
+
if (currentState !== originalValues.state) {
|
|
1579
|
+
payload.state = currentState;
|
|
1580
|
+
}
|
|
1581
|
+
const currentCities = cities.map((c) => c.value);
|
|
1582
|
+
const citiesChanged = currentCities.length !== originalValues.cities.length || currentCities.some((city, index) => city !== originalValues.cities[index]);
|
|
1583
|
+
if (citiesChanged) {
|
|
1584
|
+
payload.cities = currentCities;
|
|
1585
|
+
}
|
|
1586
|
+
const currentLanguage = language == null ? void 0 : language.value;
|
|
1587
|
+
if (currentLanguage !== originalValues.language) {
|
|
1588
|
+
payload.language = currentLanguage;
|
|
1589
|
+
}
|
|
1590
|
+
const currentTone = tone == null ? void 0 : tone.value;
|
|
1591
|
+
if (currentTone !== originalValues.tone) {
|
|
1592
|
+
payload.tone = currentTone;
|
|
1593
|
+
}
|
|
1594
|
+
const currentStyle = style == null ? void 0 : style.value;
|
|
1595
|
+
if (currentStyle !== originalValues.style) {
|
|
1596
|
+
payload.style = currentStyle;
|
|
1597
|
+
}
|
|
1598
|
+
const currentWordCount = wordCount == null ? void 0 : wordCount.value;
|
|
1599
|
+
if (currentWordCount !== originalValues.wordCount) {
|
|
1600
|
+
payload.wordCount = currentWordCount;
|
|
1601
|
+
}
|
|
1602
|
+
if (includeQuotes !== originalValues.includeQuotes) {
|
|
1603
|
+
payload.includeQuotes = includeQuotes;
|
|
1604
|
+
}
|
|
1605
|
+
if (includeFAQ !== originalValues.includeFAQ) {
|
|
1606
|
+
payload.includeFAQ = includeFAQ;
|
|
1607
|
+
}
|
|
1608
|
+
if (targetAudience !== originalValues.targetAudience) {
|
|
1609
|
+
payload.targetAudience = targetAudience;
|
|
1610
|
+
}
|
|
1611
|
+
if (Object.keys(payload).length === 0) {
|
|
1612
|
+
toast.error("No changes to save");
|
|
1613
|
+
setSaving(false);
|
|
1614
|
+
return;
|
|
1615
|
+
}
|
|
1616
|
+
const updatedPreferences = await savePreferencesApi(payload);
|
|
1617
|
+
if (updatedPreferences) {
|
|
1618
|
+
updatePreferences(updatedPreferences);
|
|
1619
|
+
} else {
|
|
1620
|
+
await refreshPreferences();
|
|
1621
|
+
}
|
|
1622
|
+
setSuccess(true);
|
|
1623
|
+
setLogo(null);
|
|
1624
|
+
toast.success("Preferences saved successfully!");
|
|
1625
|
+
} catch (error) {
|
|
1626
|
+
console.error(error);
|
|
1627
|
+
toast.error("Failed to save preferences");
|
|
1488
1628
|
} finally {
|
|
1489
|
-
|
|
1629
|
+
setSaving(false);
|
|
1490
1630
|
}
|
|
1491
1631
|
};
|
|
1492
|
-
|
|
1493
|
-
{
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
}),
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1632
|
+
if (loading) {
|
|
1633
|
+
return /* @__PURE__ */ jsx10("div", { className: "cnfy-dash-page", children: /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-page-subtitle", children: "Loading settings..." }) });
|
|
1634
|
+
}
|
|
1635
|
+
return /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-page", children: [
|
|
1636
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
|
|
1637
|
+
/* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title", children: "Chatbot Settings" }),
|
|
1638
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1639
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Chatbot Name" }),
|
|
1640
|
+
/* @__PURE__ */ jsx10(
|
|
1641
|
+
"input",
|
|
1642
|
+
{
|
|
1643
|
+
value: botName,
|
|
1644
|
+
onChange: (e) => setBotName(e.target.value),
|
|
1645
|
+
className: "cnfy-dash-input",
|
|
1646
|
+
placeholder: "Contenify AI"
|
|
1647
|
+
}
|
|
1648
|
+
)
|
|
1649
|
+
] }),
|
|
1650
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1651
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Chatbot Logo" }),
|
|
1652
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-logo-upload", children: [
|
|
1653
|
+
/* @__PURE__ */ jsx10("div", { className: "cnfy-logo-preview", children: logo ? /* @__PURE__ */ jsx10(
|
|
1654
|
+
"img",
|
|
1655
|
+
{
|
|
1656
|
+
src: URL.createObjectURL(logo),
|
|
1657
|
+
alt: "Logo preview",
|
|
1658
|
+
className: "cnfy-logo-img"
|
|
1659
|
+
}
|
|
1660
|
+
) : logoUrl ? /* @__PURE__ */ jsx10(
|
|
1661
|
+
"img",
|
|
1662
|
+
{
|
|
1663
|
+
src: logoUrl,
|
|
1664
|
+
alt: "Current logo",
|
|
1665
|
+
className: "cnfy-logo-img"
|
|
1666
|
+
}
|
|
1667
|
+
) : /* @__PURE__ */ jsx10("span", { className: "cnfy-logo-placeholder", children: "No logo" }) }),
|
|
1668
|
+
/* @__PURE__ */ jsx10(
|
|
1669
|
+
"input",
|
|
1670
|
+
{
|
|
1671
|
+
type: "file",
|
|
1672
|
+
accept: "image/*",
|
|
1673
|
+
onChange: (e) => {
|
|
1674
|
+
var _a2;
|
|
1675
|
+
return setLogo(((_a2 = e.target.files) == null ? void 0 : _a2[0]) || null);
|
|
1676
|
+
},
|
|
1677
|
+
className: "cnfy-file-input"
|
|
1678
|
+
}
|
|
1679
|
+
)
|
|
1680
|
+
] })
|
|
1681
|
+
] })
|
|
1682
|
+
] }),
|
|
1683
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
|
|
1684
|
+
/* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title", children: "Localization Settings" }),
|
|
1685
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1686
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "State" }),
|
|
1687
|
+
/* @__PURE__ */ jsx10(
|
|
1688
|
+
ClientSelect_default,
|
|
1689
|
+
{
|
|
1690
|
+
options: STATE_OPTIONS,
|
|
1691
|
+
value: state,
|
|
1692
|
+
onChange: (option) => setState(option),
|
|
1693
|
+
placeholder: "Select state"
|
|
1694
|
+
}
|
|
1695
|
+
)
|
|
1696
|
+
] }),
|
|
1697
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1698
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Cities" }),
|
|
1699
|
+
/* @__PURE__ */ jsx10(
|
|
1700
|
+
ClientSelect_default,
|
|
1701
|
+
{
|
|
1702
|
+
isMulti: true,
|
|
1703
|
+
options: CITY_OPTIONS,
|
|
1704
|
+
value: cities,
|
|
1705
|
+
onChange: (options) => setCities(options),
|
|
1706
|
+
placeholder: "Select cities",
|
|
1707
|
+
isDisabled: !state
|
|
1708
|
+
}
|
|
1709
|
+
)
|
|
1710
|
+
] }),
|
|
1711
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1712
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Language" }),
|
|
1713
|
+
/* @__PURE__ */ jsx10(
|
|
1714
|
+
ClientSelect_default,
|
|
1715
|
+
{
|
|
1716
|
+
options: LANGUAGE_OPTIONS,
|
|
1717
|
+
value: language,
|
|
1718
|
+
onChange: (option) => setLanguage(option),
|
|
1719
|
+
placeholder: "Select language"
|
|
1720
|
+
}
|
|
1721
|
+
)
|
|
1722
|
+
] })
|
|
1723
|
+
] }),
|
|
1724
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
|
|
1725
|
+
/* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title", children: "Content Generation Settings" }),
|
|
1726
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1727
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Tone" }),
|
|
1728
|
+
/* @__PURE__ */ jsx10(
|
|
1729
|
+
ClientSelect_default,
|
|
1730
|
+
{
|
|
1731
|
+
options: TONE_OPTIONS,
|
|
1732
|
+
value: tone,
|
|
1733
|
+
onChange: (option) => setTone(option),
|
|
1734
|
+
placeholder: "Select tone"
|
|
1735
|
+
}
|
|
1736
|
+
),
|
|
1737
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "The writing tone for generated content" })
|
|
1738
|
+
] }),
|
|
1739
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1740
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Style" }),
|
|
1741
|
+
/* @__PURE__ */ jsx10(
|
|
1742
|
+
ClientSelect_default,
|
|
1743
|
+
{
|
|
1744
|
+
options: STYLE_OPTIONS,
|
|
1745
|
+
value: style,
|
|
1746
|
+
onChange: (option) => setStyle(option),
|
|
1747
|
+
placeholder: "Select style"
|
|
1748
|
+
}
|
|
1749
|
+
),
|
|
1750
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "The format/style of generated articles" })
|
|
1751
|
+
] }),
|
|
1752
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1753
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Word Count" }),
|
|
1754
|
+
/* @__PURE__ */ jsx10(
|
|
1755
|
+
ClientSelect_default,
|
|
1756
|
+
{
|
|
1757
|
+
options: WORD_COUNT_OPTIONS,
|
|
1758
|
+
value: wordCount,
|
|
1759
|
+
onChange: (option) => setWordCount(option),
|
|
1760
|
+
placeholder: "Select word count"
|
|
1761
|
+
}
|
|
1762
|
+
),
|
|
1763
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "Target length for generated content" })
|
|
1764
|
+
] }),
|
|
1765
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-field", children: [
|
|
1766
|
+
/* @__PURE__ */ jsx10("label", { className: "cnfy-dash-label", children: "Target Audience" }),
|
|
1767
|
+
/* @__PURE__ */ jsx10(
|
|
1768
|
+
"input",
|
|
1769
|
+
{
|
|
1770
|
+
value: targetAudience,
|
|
1771
|
+
onChange: (e) => setTargetAudience(e.target.value),
|
|
1772
|
+
className: "cnfy-dash-input",
|
|
1773
|
+
placeholder: "e.g. tech-savvy millennials, business professionals"
|
|
1774
|
+
}
|
|
1775
|
+
),
|
|
1776
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-dash-hint", children: "Describe your target audience for personalized content" })
|
|
1777
|
+
] }),
|
|
1778
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-toggle-group", children: [
|
|
1779
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-toggle-row", children: [
|
|
1780
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
1781
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-label", children: "Include Quotes" }),
|
|
1782
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-desc", children: "Add relevant quotes to generated articles" })
|
|
1783
|
+
] }),
|
|
1784
|
+
/* @__PURE__ */ jsx10(
|
|
1785
|
+
"button",
|
|
1786
|
+
{
|
|
1787
|
+
type: "button",
|
|
1788
|
+
role: "switch",
|
|
1789
|
+
"aria-checked": includeQuotes,
|
|
1790
|
+
onClick: () => setIncludeQuotes(!includeQuotes),
|
|
1791
|
+
className: "cnfy-toggle",
|
|
1792
|
+
style: { backgroundColor: includeQuotes ? primaryColor : "#d1d5db" },
|
|
1793
|
+
children: /* @__PURE__ */ jsx10(
|
|
1794
|
+
"span",
|
|
1795
|
+
{
|
|
1796
|
+
className: `cnfy-toggle-thumb ${includeQuotes ? "cnfy-toggle-thumb--on" : ""}`
|
|
1797
|
+
}
|
|
1798
|
+
)
|
|
1799
|
+
}
|
|
1800
|
+
)
|
|
1801
|
+
] }),
|
|
1802
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-toggle-row", children: [
|
|
1803
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
1804
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-label", children: "Include FAQ Section" }),
|
|
1805
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-toggle-desc", children: "Add FAQ section at the end of articles" })
|
|
1806
|
+
] }),
|
|
1807
|
+
/* @__PURE__ */ jsx10(
|
|
1808
|
+
"button",
|
|
1809
|
+
{
|
|
1810
|
+
type: "button",
|
|
1811
|
+
role: "switch",
|
|
1812
|
+
"aria-checked": includeFAQ,
|
|
1813
|
+
onClick: () => setIncludeFAQ(!includeFAQ),
|
|
1814
|
+
className: "cnfy-toggle",
|
|
1815
|
+
style: { backgroundColor: includeFAQ ? primaryColor : "#d1d5db" },
|
|
1816
|
+
children: /* @__PURE__ */ jsx10(
|
|
1817
|
+
"span",
|
|
1818
|
+
{
|
|
1819
|
+
className: `cnfy-toggle-thumb ${includeFAQ ? "cnfy-toggle-thumb--on" : ""}`
|
|
1820
|
+
}
|
|
1821
|
+
)
|
|
1822
|
+
}
|
|
1823
|
+
)
|
|
1824
|
+
] })
|
|
1825
|
+
] })
|
|
1826
|
+
] }),
|
|
1827
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card", children: [
|
|
1828
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-card-header", children: [
|
|
1829
|
+
/* @__PURE__ */ jsx10("h2", { className: "cnfy-dash-card-title-inline", children: "News Scraping" }),
|
|
1830
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-dash-card-desc", children: "Scrape latest news from your configured locations" })
|
|
1831
|
+
] }),
|
|
1832
|
+
!loadingStatus && scrapeStatus && /* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-grid cnfy-dash-grid--sm", children: [
|
|
1833
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
1834
|
+
/* @__PURE__ */ jsx10("span", { className: "cnfy-dash-label-muted", children: "Status:" }),
|
|
1835
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-dash-label-bold", children: scrapeStatus.isRunning ? /* @__PURE__ */ jsx10("span", { className: "cnfy-dash-badge cnfy-dash-badge--yellow", children: "Running" }) : /* @__PURE__ */ jsx10("span", { className: "cnfy-dash-badge cnfy-dash-badge--green", children: "Idle" }) })
|
|
1836
|
+
] }),
|
|
1837
|
+
scrapeStatus.lastRun && /* @__PURE__ */ jsxs7("div", { children: [
|
|
1838
|
+
/* @__PURE__ */ jsx10("span", { className: "cnfy-dash-label-muted", children: "Last Run:" }),
|
|
1839
|
+
/* @__PURE__ */ jsx10("p", { className: "cnfy-dash-label-bold", children: new Date(scrapeStatus.lastRun).toLocaleString() })
|
|
1840
|
+
] }),
|
|
1841
|
+
scrapeStatus.totalScraped !== void 0 && /* @__PURE__ */ jsxs7("div", { children: [
|
|
1842
|
+
/* @__PURE__ */ jsx10("span", { className: "cnfy-dash-label-muted", children: "Total Scraped:" }),
|
|
1843
|
+
/* @__PURE__ */ jsxs7("p", { className: "cnfy-dash-label-bold", children: [
|
|
1844
|
+
scrapeStatus.totalScraped.toLocaleString(),
|
|
1845
|
+
" articles"
|
|
1846
|
+
] })
|
|
1847
|
+
] })
|
|
1848
|
+
] }),
|
|
1849
|
+
/* @__PURE__ */ jsxs7("div", { children: [
|
|
1850
|
+
/* @__PURE__ */ jsxs7("p", { className: "cnfy-dash-info-text", children: [
|
|
1851
|
+
"Current configuration: ",
|
|
1852
|
+
/* @__PURE__ */ jsx10("strong", { children: (_b = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _b.state }),
|
|
1853
|
+
((_c = preferences == null ? void 0 : preferences.localization) == null ? void 0 : _c.cities) && preferences.localization.cities.length > 0 && /* @__PURE__ */ jsxs7(Fragment, { children: [
|
|
1854
|
+
" - ",
|
|
1855
|
+
preferences.localization.cities.join(", ")
|
|
1856
|
+
] })
|
|
1857
|
+
] }),
|
|
1858
|
+
/* @__PURE__ */ jsx10(
|
|
1859
|
+
"button",
|
|
1860
|
+
{
|
|
1861
|
+
onClick: handleScrape,
|
|
1862
|
+
disabled: scraping || (scrapeStatus == null ? void 0 : scrapeStatus.isRunning),
|
|
1863
|
+
className: "cnfy-dash-btn-save",
|
|
1864
|
+
style: { backgroundColor: primaryColor },
|
|
1865
|
+
children: scraping ? "Starting Scrape..." : (scrapeStatus == null ? void 0 : scrapeStatus.isRunning) ? "Scraping in Progress..." : "Start Scraping"
|
|
1866
|
+
}
|
|
1867
|
+
)
|
|
1868
|
+
] })
|
|
1869
|
+
] }),
|
|
1870
|
+
/* @__PURE__ */ jsxs7("div", { className: "cnfy-dash-actions", children: [
|
|
1871
|
+
/* @__PURE__ */ jsx10(
|
|
1872
|
+
"button",
|
|
1873
|
+
{
|
|
1874
|
+
onClick: handleSave,
|
|
1875
|
+
disabled: saving,
|
|
1876
|
+
className: "cnfy-dash-btn-save",
|
|
1877
|
+
style: { backgroundColor: primaryColor },
|
|
1878
|
+
children: saving ? "Saving..." : "Save Preferences"
|
|
1540
1879
|
}
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
"button",
|
|
1545
|
-
{
|
|
1546
|
-
onClick: handleScrape,
|
|
1547
|
-
disabled: scraping,
|
|
1548
|
-
className: "cnfy-scrape-btn",
|
|
1549
|
-
title: "Fetch latest news",
|
|
1550
|
-
children: [
|
|
1551
|
-
/* @__PURE__ */ jsx10(RefreshCcw3, { size: 14, className: scraping ? "cnfy-animate-spin" : "" }),
|
|
1552
|
-
scraping ? "Scraping..." : "Scrape"
|
|
1553
|
-
]
|
|
1554
|
-
}
|
|
1555
|
-
),
|
|
1556
|
-
!selectedSource && /* @__PURE__ */ jsxs9(
|
|
1557
|
-
"button",
|
|
1558
|
-
{
|
|
1559
|
-
onClick: () => fetchNews(null),
|
|
1560
|
-
disabled: fetchingNews,
|
|
1561
|
-
className: "cnfy-refresh-btn",
|
|
1562
|
-
children: [
|
|
1563
|
-
/* @__PURE__ */ jsx10(RefreshCcw3, { size: 14, className: fetchingNews ? "cnfy-animate-spin" : "" }),
|
|
1564
|
-
"Refresh"
|
|
1565
|
-
]
|
|
1566
|
-
}
|
|
1567
|
-
)
|
|
1880
|
+
),
|
|
1881
|
+
success && /* @__PURE__ */ jsx10("p", { className: "cnfy-dash-success", style: { color: primaryColor }, children: "Preferences saved successfully \u2705" })
|
|
1882
|
+
] })
|
|
1568
1883
|
] });
|
|
1569
1884
|
}
|
|
1570
1885
|
|
|
@@ -1588,7 +1903,7 @@ var createContentStreamApi = async ({
|
|
|
1588
1903
|
}) => {
|
|
1589
1904
|
var _a;
|
|
1590
1905
|
const API_BASE_URL = getApiBaseUrl();
|
|
1591
|
-
const apiKey =
|
|
1906
|
+
const apiKey = getApiKey();
|
|
1592
1907
|
const headers = {
|
|
1593
1908
|
"Content-Type": "application/json"
|
|
1594
1909
|
};
|
|
@@ -1681,7 +1996,7 @@ var rewriteNewsStreamApi = async ({
|
|
|
1681
1996
|
if (targetAudience) payload.targetAudience = targetAudience;
|
|
1682
1997
|
try {
|
|
1683
1998
|
const API_BASE_URL = getApiBaseUrl();
|
|
1684
|
-
const apiKey =
|
|
1999
|
+
const apiKey = getApiKey();
|
|
1685
2000
|
console.log("\u{1F680} Starting stream request to:", `${API_BASE_URL}/chat/rewrite/stream`);
|
|
1686
2001
|
console.log("\u{1F4E6} Payload:", payload);
|
|
1687
2002
|
const headers = {
|
|
@@ -1810,32 +2125,18 @@ var rewriteNewsApi = async ({
|
|
|
1810
2125
|
};
|
|
1811
2126
|
|
|
1812
2127
|
// components/chatbot/ChatBot.tsx
|
|
1813
|
-
import
|
|
2128
|
+
import toast2 from "react-hot-toast";
|
|
1814
2129
|
import { Loader2 } from "lucide-react";
|
|
1815
|
-
import { jsx as jsx11, jsxs as
|
|
1816
|
-
function ChatBot({
|
|
1817
|
-
|
|
1818
|
-
onLogout
|
|
1819
|
-
} = {}) {
|
|
1820
|
-
const { loading, showNewsPanel } = useTheme();
|
|
2130
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2131
|
+
function ChatBot({ onPost }) {
|
|
2132
|
+
const { loading } = useTheme();
|
|
1821
2133
|
const { preferences } = usePreferences();
|
|
1822
|
-
const [
|
|
1823
|
-
const [
|
|
1824
|
-
const [
|
|
1825
|
-
const [
|
|
1826
|
-
const [messages, setMessages] = useState8([]);
|
|
1827
|
-
const [showChatMobile, setShowChatMobile] = useState8(false);
|
|
1828
|
-
const [isStreaming, setIsStreaming] = useState8(false);
|
|
1829
|
-
const [analyzedData, setAnalyzedData] = useState8(null);
|
|
1830
|
-
const handleNewsLoaded = useCallback3((loadedNews) => {
|
|
1831
|
-
setNews(loadedNews);
|
|
1832
|
-
}, []);
|
|
1833
|
-
const handleLoadingChange = useCallback3((isLoading) => {
|
|
1834
|
-
setNewsLoading(isLoading);
|
|
1835
|
-
}, []);
|
|
2134
|
+
const [preferencesOpen, setPreferencesOpen] = useState7(false);
|
|
2135
|
+
const [messages, setMessages] = useState7([]);
|
|
2136
|
+
const [isStreaming, setIsStreaming] = useState7(false);
|
|
2137
|
+
const [analyzedData, setAnalyzedData] = useState7(null);
|
|
1836
2138
|
const handleRecreate = async ({ title, content, id }) => {
|
|
1837
2139
|
var _a;
|
|
1838
|
-
setShowChatMobile(true);
|
|
1839
2140
|
const assistantId = crypto.randomUUID();
|
|
1840
2141
|
setMessages((prev) => [
|
|
1841
2142
|
...prev,
|
|
@@ -1878,7 +2179,7 @@ ${title}`
|
|
|
1878
2179
|
},
|
|
1879
2180
|
onComplete: () => {
|
|
1880
2181
|
console.log("Streaming completed successfully");
|
|
1881
|
-
|
|
2182
|
+
toast2.success("Article created successfully!");
|
|
1882
2183
|
},
|
|
1883
2184
|
onError: async (error) => {
|
|
1884
2185
|
console.error("Streaming error:", error);
|
|
@@ -1886,7 +2187,7 @@ ${title}`
|
|
|
1886
2187
|
console.log("Falling back to regular API...");
|
|
1887
2188
|
throw error;
|
|
1888
2189
|
} else {
|
|
1889
|
-
|
|
2190
|
+
toast2.error("Failed to complete article generation");
|
|
1890
2191
|
setMessages(
|
|
1891
2192
|
(prev) => prev.map(
|
|
1892
2193
|
(m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: accumulatedContent || "\u274C Failed to create article. Please try again." }) : m
|
|
@@ -1918,11 +2219,11 @@ ${title}`
|
|
|
1918
2219
|
(m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: result.article || result }) : m
|
|
1919
2220
|
)
|
|
1920
2221
|
);
|
|
1921
|
-
|
|
2222
|
+
toast2.success("Article created successfully!");
|
|
1922
2223
|
}
|
|
1923
2224
|
} catch (err) {
|
|
1924
2225
|
console.error("Complete Error:", err);
|
|
1925
|
-
|
|
2226
|
+
toast2.error((err == null ? void 0 : err.message) || "An error occurred while creating the article");
|
|
1926
2227
|
setMessages(
|
|
1927
2228
|
(prev) => prev.map(
|
|
1928
2229
|
(m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: "\u274C Failed to create article. Please try again." }) : m
|
|
@@ -1973,7 +2274,7 @@ ${optionsList}`
|
|
|
1973
2274
|
}
|
|
1974
2275
|
} catch (err) {
|
|
1975
2276
|
console.error("Analyze input error:", err);
|
|
1976
|
-
|
|
2277
|
+
toast2.error("Failed to analyze the link");
|
|
1977
2278
|
setMessages(
|
|
1978
2279
|
(prev) => prev.map(
|
|
1979
2280
|
(m) => m.id === assistantId ? __spreadProps(__spreadValues({}, m), { content: "\u274C Failed to analyze the link. Please try again." }) : m
|
|
@@ -2009,12 +2310,12 @@ ${optionsList}`
|
|
|
2009
2310
|
},
|
|
2010
2311
|
onComplete: () => {
|
|
2011
2312
|
setIsStreaming(false);
|
|
2012
|
-
|
|
2313
|
+
toast2.success("Content generated!");
|
|
2013
2314
|
},
|
|
2014
2315
|
onError: (error) => {
|
|
2015
2316
|
console.error("Stream error:", error);
|
|
2016
2317
|
setIsStreaming(false);
|
|
2017
|
-
|
|
2318
|
+
toast2.error("Failed to generate content");
|
|
2018
2319
|
}
|
|
2019
2320
|
});
|
|
2020
2321
|
} catch (err) {
|
|
@@ -2062,12 +2363,12 @@ ${optionsList}`
|
|
|
2062
2363
|
},
|
|
2063
2364
|
onComplete: () => {
|
|
2064
2365
|
setIsStreaming(false);
|
|
2065
|
-
|
|
2366
|
+
toast2.success("Content created!");
|
|
2066
2367
|
},
|
|
2067
2368
|
onError: (error) => {
|
|
2068
2369
|
console.error("Stream error:", error);
|
|
2069
2370
|
setIsStreaming(false);
|
|
2070
|
-
|
|
2371
|
+
toast2.error("Failed to create content");
|
|
2071
2372
|
}
|
|
2072
2373
|
});
|
|
2073
2374
|
} catch (e) {
|
|
@@ -2082,7 +2383,7 @@ ${optionsList}`
|
|
|
2082
2383
|
)
|
|
2083
2384
|
);
|
|
2084
2385
|
setIsStreaming(false);
|
|
2085
|
-
|
|
2386
|
+
toast2.success("Content created!");
|
|
2086
2387
|
}
|
|
2087
2388
|
} catch (err) {
|
|
2088
2389
|
console.error("Create content error:", err);
|
|
@@ -2095,74 +2396,38 @@ ${optionsList}`
|
|
|
2095
2396
|
}
|
|
2096
2397
|
};
|
|
2097
2398
|
if (loading) {
|
|
2098
|
-
return /* @__PURE__ */ jsx11("div", { className: "cnfy-loading", children: /* @__PURE__ */
|
|
2399
|
+
return /* @__PURE__ */ jsx11("div", { className: "cnfy-loading", children: /* @__PURE__ */ jsxs8("div", { className: "cnfy-loading-inner", children: [
|
|
2099
2400
|
/* @__PURE__ */ jsx11(Loader2, { className: "cnfy-loading-spinner cnfy-animate-spin" }),
|
|
2100
2401
|
/* @__PURE__ */ jsx11("p", { className: "cnfy-loading-text", children: "Loading..." })
|
|
2101
2402
|
] }) });
|
|
2102
2403
|
}
|
|
2103
|
-
return /* @__PURE__ */
|
|
2104
|
-
/* @__PURE__ */ jsx11(HeaderBar, {
|
|
2105
|
-
/* @__PURE__ */
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
SourceSelector,
|
|
2109
|
-
{
|
|
2110
|
-
selectedSource,
|
|
2111
|
-
onSourceChange: (value) => {
|
|
2112
|
-
console.log("Selected source:", value);
|
|
2113
|
-
setSelectedSource(value);
|
|
2114
|
-
},
|
|
2115
|
-
onNewsLoaded: handleNewsLoaded,
|
|
2116
|
-
onLoadingChange: handleLoadingChange
|
|
2117
|
-
}
|
|
2118
|
-
) }),
|
|
2119
|
-
/* @__PURE__ */ jsx11(
|
|
2120
|
-
TrendingNews,
|
|
2121
|
-
{
|
|
2122
|
-
onRecreate: handleRecreate,
|
|
2123
|
-
news,
|
|
2124
|
-
isLoading: newsLoading
|
|
2125
|
-
}
|
|
2126
|
-
)
|
|
2127
|
-
] }),
|
|
2128
|
-
/* @__PURE__ */ jsxs10(
|
|
2129
|
-
"section",
|
|
2404
|
+
return /* @__PURE__ */ jsxs8("div", { className: "cnfy-root", children: [
|
|
2405
|
+
/* @__PURE__ */ jsx11(HeaderBar, { onOpenPreferences: () => setPreferencesOpen(true) }),
|
|
2406
|
+
/* @__PURE__ */ jsx11("div", { className: "cnfy-main", children: /* @__PURE__ */ jsxs8("section", { className: "cnfy-chat-section cnfy-chat-section--full", children: [
|
|
2407
|
+
/* @__PURE__ */ jsx11("div", { className: "cnfy-chat-inner", children: /* @__PURE__ */ jsx11(
|
|
2408
|
+
ChatWindow,
|
|
2130
2409
|
{
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
children: "\u2190 Back to news"
|
|
2139
|
-
}
|
|
2140
|
-
) }),
|
|
2141
|
-
/* @__PURE__ */ jsx11("div", { className: "cnfy-chat-inner", children: /* @__PURE__ */ jsx11(
|
|
2142
|
-
ChatWindow,
|
|
2143
|
-
{
|
|
2144
|
-
messages,
|
|
2145
|
-
onSend: handleSendMessage,
|
|
2146
|
-
onSelectNews: handleRecreate,
|
|
2147
|
-
isStreaming,
|
|
2148
|
-
analyzedData,
|
|
2149
|
-
onSelectAction: handleSelectAction
|
|
2150
|
-
}
|
|
2151
|
-
) }),
|
|
2152
|
-
!messages.length && /* @__PURE__ */ jsx11("div", { className: "cnfy-empty-state", children: /* @__PURE__ */ jsxs10("div", { children: [
|
|
2153
|
-
/* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-title", children: "AI News Assistant" }),
|
|
2154
|
-
/* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-subtitle", children: "Select a news article or type a message to begin" })
|
|
2155
|
-
] }) })
|
|
2156
|
-
]
|
|
2410
|
+
messages,
|
|
2411
|
+
onSend: handleSendMessage,
|
|
2412
|
+
onSelectNews: handleRecreate,
|
|
2413
|
+
isStreaming,
|
|
2414
|
+
analyzedData,
|
|
2415
|
+
onSelectAction: handleSelectAction,
|
|
2416
|
+
onPost
|
|
2157
2417
|
}
|
|
2158
|
-
)
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2418
|
+
) }),
|
|
2419
|
+
!messages.length && /* @__PURE__ */ jsx11("div", { className: "cnfy-empty-state", children: /* @__PURE__ */ jsxs8("div", { children: [
|
|
2420
|
+
/* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-title", children: "AI News Assistant" }),
|
|
2421
|
+
/* @__PURE__ */ jsx11("p", { className: "cnfy-empty-state-subtitle", children: "Type a message or paste a link to begin" })
|
|
2422
|
+
] }) })
|
|
2423
|
+
] }) }),
|
|
2424
|
+
/* @__PURE__ */ jsx11(
|
|
2425
|
+
Drawer,
|
|
2162
2426
|
{
|
|
2163
|
-
|
|
2164
|
-
onClose: () =>
|
|
2165
|
-
|
|
2427
|
+
open: preferencesOpen,
|
|
2428
|
+
onClose: () => setPreferencesOpen(false),
|
|
2429
|
+
title: "Settings",
|
|
2430
|
+
children: /* @__PURE__ */ jsx11(PreferencesPage, {})
|
|
2166
2431
|
}
|
|
2167
2432
|
)
|
|
2168
2433
|
] });
|
|
@@ -2170,12 +2435,16 @@ ${optionsList}`
|
|
|
2170
2435
|
|
|
2171
2436
|
// src/index.tsx
|
|
2172
2437
|
import { jsx as jsx12 } from "react/jsx-runtime";
|
|
2173
|
-
function ContenifyChatBot({
|
|
2174
|
-
|
|
2438
|
+
function ContenifyChatBot({ apiUrl, apiKey, domain, onPost }) {
|
|
2439
|
+
useEffect8(() => {
|
|
2440
|
+
setConfig({ apiUrl, apiKey, domain });
|
|
2441
|
+
}, [apiUrl, apiKey, domain]);
|
|
2442
|
+
return /* @__PURE__ */ jsx12(PreferencesProvider, { children: /* @__PURE__ */ jsx12(ChatBot, { onPost }) });
|
|
2175
2443
|
}
|
|
2176
2444
|
var index_default = ContenifyChatBot;
|
|
2177
2445
|
export {
|
|
2178
2446
|
ContenifyChatBot,
|
|
2179
|
-
index_default as default
|
|
2447
|
+
index_default as default,
|
|
2448
|
+
setConfig
|
|
2180
2449
|
};
|
|
2181
2450
|
//# sourceMappingURL=index.mjs.map
|