@retrivora-ai/rag-engine 0.4.5 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +32 -57
  2. package/dist/{ChromaDBProvider-GI7TB7GJ.mjs → ChromaDBProvider-MIDOR4FW.mjs} +2 -2
  3. package/dist/{DocumentChunker-3yElxTO3.d.mts → DocumentChunker-C-sCZPhi.d.mts} +6 -6
  4. package/dist/{DocumentChunker-3yElxTO3.d.ts → DocumentChunker-C-sCZPhi.d.ts} +6 -6
  5. package/dist/{MilvusProvider-WDVTFB7D.mjs → MilvusProvider-U7SKC27V.mjs} +2 -2
  6. package/dist/{MongoDBProvider-RE3Q5S5B.mjs → MongoDBProvider-Z6ALOVDN.mjs} +2 -2
  7. package/dist/{PineconeProvider-BE2JWSPD.mjs → PineconeProvider-QZNRKTN2.mjs} +2 -2
  8. package/dist/{PostgreSQLProvider-5HHTK4SU.mjs → PostgreSQLProvider-BMOETDZA.mjs} +2 -2
  9. package/dist/{QdrantProvider-XVDVBNIG.mjs → QdrantProvider-YNUNEOZH.mjs} +2 -2
  10. package/dist/{RagConfig-BgRDL9Vy.d.mts → RagConfig-DRJO4hGU.d.mts} +12 -1
  11. package/dist/{RagConfig-BgRDL9Vy.d.ts → RagConfig-DRJO4hGU.d.ts} +12 -1
  12. package/dist/{RedisProvider-EK2R2PQH.mjs → RedisProvider-SR65SCKV.mjs} +2 -2
  13. package/dist/{SimpleGraphProvider-M6T7SE7D.mjs → SimpleGraphProvider-SLOXO4M7.mjs} +1 -1
  14. package/dist/{UniversalVectorProvider-YIDRX6VT.mjs → UniversalVectorProvider-IN67OS56.mjs} +3 -3
  15. package/dist/{WeaviateProvider-4CAPQ7UY.mjs → WeaviateProvider-5FWDFITI.mjs} +2 -2
  16. package/dist/{chunk-5KNBWQM6.mjs → chunk-3DSHW676.mjs} +5 -1
  17. package/dist/{chunk-PRC5CZIZ.mjs → chunk-5W2YWFT3.mjs} +1248 -1361
  18. package/dist/{chunk-H6RKMU7W.mjs → chunk-5YGUXK7Z.mjs} +1 -1
  19. package/dist/{chunk-PQKTC73Y.mjs → chunk-CD6TSNL4.mjs} +67 -6
  20. package/dist/{chunk-RK2UDJA2.mjs → chunk-CFVEZTBJ.mjs} +1 -1
  21. package/dist/{chunk-LJWWPTWE.mjs → chunk-FLOSGE6A.mjs} +76 -14
  22. package/dist/{chunk-GQT5LF4G.mjs → chunk-LR3VMDVK.mjs} +2 -2
  23. package/dist/{chunk-KTS3LLHY.mjs → chunk-M6JSPGAR.mjs} +5 -5
  24. package/dist/{chunk-3QWAK3RZ.mjs → chunk-U55XRW3U.mjs} +6 -2
  25. package/dist/{chunk-XCNXPECE.mjs → chunk-VUQJVIJT.mjs} +55 -1
  26. package/dist/chunk-X4TOT24V.mjs +89 -0
  27. package/dist/{chunk-EDLTMSNY.mjs → chunk-YLTMFW4M.mjs} +1 -1
  28. package/dist/handlers/index.d.mts +2 -2
  29. package/dist/handlers/index.d.ts +2 -2
  30. package/dist/handlers/index.js +1488 -1371
  31. package/dist/handlers/index.mjs +5 -3
  32. package/dist/index-B2mutkgp.d.ts +116 -0
  33. package/dist/index-Bjy0es5a.d.mts +116 -0
  34. package/dist/index.d.mts +17 -11
  35. package/dist/index.d.ts +17 -11
  36. package/dist/index.js +253 -363
  37. package/dist/index.mjs +243 -353
  38. package/dist/server.d.mts +108 -158
  39. package/dist/server.d.ts +108 -158
  40. package/dist/server.js +1452 -1386
  41. package/dist/server.mjs +12 -12
  42. package/package.json +5 -1
  43. package/src/config/RagConfig.ts +7 -0
  44. package/src/core/ConfigValidator.ts +66 -492
  45. package/src/core/LangChainAgent.ts +78 -0
  46. package/src/core/Pipeline.ts +210 -240
  47. package/src/core/ProviderHealthCheck.ts +35 -406
  48. package/src/core/ProviderInterfaces.ts +37 -0
  49. package/src/core/ProviderRegistry.ts +70 -55
  50. package/src/core/QueryProcessor.ts +173 -0
  51. package/src/core/VectorPlugin.ts +7 -0
  52. package/src/handlers/index.ts +45 -0
  53. package/src/llm/ILLMProvider.ts +10 -0
  54. package/src/llm/LLMFactory.ts +33 -13
  55. package/src/llm/providers/AnthropicProvider.ts +55 -15
  56. package/src/llm/providers/GeminiProvider.ts +51 -0
  57. package/src/llm/providers/OllamaProvider.ts +100 -15
  58. package/src/llm/providers/OpenAIProvider.ts +60 -11
  59. package/src/providers/vectordb/BaseVectorProvider.ts +11 -0
  60. package/src/providers/vectordb/MilvusProvider.ts +4 -0
  61. package/src/providers/vectordb/MongoDBProvider.ts +72 -8
  62. package/src/providers/vectordb/PineconeProvider.ts +60 -5
  63. package/src/providers/vectordb/PostgreSQLProvider.ts +84 -14
  64. package/src/providers/vectordb/QdrantProvider.ts +4 -0
  65. package/src/providers/vectordb/WeaviateProvider.ts +8 -4
  66. package/src/rag/DocumentChunker.ts +15 -19
  67. package/src/rag/EntityExtractor.ts +3 -0
  68. package/src/rag/LlamaIndexIngestor.ts +61 -0
  69. package/src/rag/Reranker.ts +20 -0
  70. package/src/server.ts +1 -1
  71. package/src/types/index.ts +9 -0
  72. package/dist/chunk-FWCSY2DS.mjs +0 -37
  73. package/dist/index-7qeLTPBL.d.mts +0 -114
  74. package/dist/index-DowY4_K0.d.ts +0 -114
package/dist/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  mergeDefined
3
- } from "./chunk-EDLTMSNY.mjs";
3
+ } from "./chunk-YLTMFW4M.mjs";
4
4
  import {
5
5
  __spreadProps,
6
6
  __spreadValues
7
- } from "./chunk-FWCSY2DS.mjs";
7
+ } from "./chunk-X4TOT24V.mjs";
8
8
 
9
9
  // src/components/ChatWidget.tsx
10
- import { useState as useState4 } from "react";
10
+ import React7, { useState as useState4 } from "react";
11
11
  import { MessageSquare as MessageSquare2, X as X2 } from "lucide-react";
12
12
 
13
13
  // src/components/ChatWindow.tsx
14
- import { useState as useState3, useRef as useRef2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
14
+ import React6, { useState as useState3, useRef as useRef2, useEffect as useEffect3, useCallback as useCallback2 } from "react";
15
15
  import {
16
16
  Bot as Bot3,
17
17
  Trash2,
@@ -30,7 +30,6 @@ import remarkGfm from "remark-gfm";
30
30
  // src/components/SourceCard.tsx
31
31
  import React from "react";
32
32
  import { ChevronDown, ChevronUp } from "lucide-react";
33
- import { Fragment, jsx, jsxs } from "react/jsx-runtime";
34
33
  function SourceCard({ source, index }) {
35
34
  var _a, _b;
36
35
  const [expanded, setExpanded] = React.useState(false);
@@ -39,37 +38,19 @@ function SourceCard({ source, index }) {
39
38
  const scoreBg = source.score >= 0.8 ? "bg-emerald-50 border-emerald-100 dark:bg-emerald-400/10 dark:border-emerald-400/20" : source.score >= 0.6 ? "bg-amber-50 border-amber-100 dark:bg-amber-400/10 dark:border-amber-400/20" : "bg-rose-50 border-rose-100 dark:bg-rose-400/10 dark:border-rose-400/20";
40
39
  const preview = source.content.slice(0, 120);
41
40
  const hasMore = source.content.length > 120;
42
- return /* @__PURE__ */ jsxs(
41
+ return /* @__PURE__ */ React.createElement(
43
42
  "div",
44
43
  {
45
44
  className: `rounded-xl border backdrop-blur-sm p-3 transition-all duration-200 hover:scale-[1.01] cursor-pointer ${scoreBg}`,
46
- onClick: () => setExpanded((e) => !e),
47
- children: [
48
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between gap-2", children: [
49
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 min-w-0", children: [
50
- /* @__PURE__ */ jsx("span", { className: "flex-shrink-0 w-5 h-5 rounded-full bg-slate-200 dark:bg-white/10 flex items-center justify-center text-[10px] font-bold text-slate-500 dark:text-white/60", children: index + 1 }),
51
- /* @__PURE__ */ jsx("span", { className: "text-xs text-slate-500 dark:text-white/50 truncate font-mono", children: (_b = (_a = source.metadata) == null ? void 0 : _a.docId) != null ? _b : source.id })
52
- ] }),
53
- /* @__PURE__ */ jsxs("span", { className: `flex-shrink-0 text-xs font-semibold ${scoreColor} tabular-nums`, children: [
54
- scorePercent,
55
- "%"
56
- ] })
57
- ] }),
58
- /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs text-slate-600 dark:text-white/70 leading-relaxed", children: expanded ? source.content : `${preview}${hasMore && !expanded ? "\u2026" : ""}` }),
59
- hasMore && /* @__PURE__ */ jsx("button", { className: "mt-1 text-[10px] text-indigo-400 hover:text-indigo-300 transition-colors flex items-center gap-0.5", children: expanded ? /* @__PURE__ */ jsxs(Fragment, { children: [
60
- /* @__PURE__ */ jsx(ChevronUp, { className: "w-3 h-3" }),
61
- " Show less"
62
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
63
- /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3" }),
64
- " Show more"
65
- ] }) })
66
- ]
67
- }
45
+ onClick: () => setExpanded((e) => !e)
46
+ },
47
+ /* @__PURE__ */ React.createElement("div", { className: "flex items-start justify-between gap-2" }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center gap-2 min-w-0" }, /* @__PURE__ */ React.createElement("span", { className: "flex-shrink-0 w-5 h-5 rounded-full bg-slate-200 dark:bg-white/10 flex items-center justify-center text-[10px] font-bold text-slate-500 dark:text-white/60" }, index + 1), /* @__PURE__ */ React.createElement("span", { className: "text-xs text-slate-500 dark:text-white/50 truncate font-mono" }, (_b = (_a = source.metadata) == null ? void 0 : _a.docId) != null ? _b : source.id)), /* @__PURE__ */ React.createElement("span", { className: `flex-shrink-0 text-xs font-semibold ${scoreColor} tabular-nums` }, scorePercent, "%")),
48
+ /* @__PURE__ */ React.createElement("p", { className: "mt-2 text-xs text-slate-600 dark:text-white/70 leading-relaxed" }, expanded ? source.content : `${preview}${hasMore && !expanded ? "\u2026" : ""}`),
49
+ hasMore && /* @__PURE__ */ React.createElement("button", { className: "mt-1 text-[10px] text-indigo-400 hover:text-indigo-300 transition-colors flex items-center gap-0.5" }, expanded ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ChevronUp, { className: "w-3 h-3" }), " Show less") : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(ChevronDown, { className: "w-3 h-3" }), " Show more"))
68
50
  );
69
51
  }
70
52
 
71
53
  // src/components/MessageBubble.tsx
72
- import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
73
54
  function MessageBubble({
74
55
  message,
75
56
  sources,
@@ -79,52 +60,36 @@ function MessageBubble({
79
60
  }) {
80
61
  const isUser = message.role === "user";
81
62
  const [showSources, setShowSources] = React2.useState(false);
82
- return /* @__PURE__ */ jsxs2("div", { className: `flex gap-3 ${isUser ? "flex-row-reverse" : "flex-row"} items-start`, children: [
83
- /* @__PURE__ */ jsx2(
84
- "div",
85
- {
86
- className: `flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center shadow-lg ${isUser ? "text-white" : "bg-slate-100 dark:bg-white/10 text-slate-700 dark:text-white/80"}`,
87
- style: isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {},
88
- children: isUser ? /* @__PURE__ */ jsx2(User, { className: "w-4 h-4 text-white" }) : /* @__PURE__ */ jsx2(Bot, { className: "w-4 h-4" })
89
- }
90
- ),
91
- /* @__PURE__ */ jsxs2("div", { className: `flex flex-col gap-1 max-w-[75%] ${isUser ? "items-end" : "items-start"}`, children: [
92
- /* @__PURE__ */ jsx2(
93
- "div",
94
- {
95
- className: `relative px-4 py-3 rounded-2xl text-sm leading-relaxed shadow-sm dark:shadow-lg ${isUser ? "text-white rounded-tr-sm" : "bg-white dark:bg-white/5 border border-slate-200 dark:border-white/10 text-slate-800 dark:text-white/90 rounded-tl-sm"}`,
96
- style: isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {},
97
- children: isStreaming ? /* @__PURE__ */ jsxs2("span", { className: "flex items-center gap-1", children: [
98
- /* @__PURE__ */ jsx2("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:0ms]" }),
99
- /* @__PURE__ */ jsx2("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:150ms]" }),
100
- /* @__PURE__ */ jsx2("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:300ms]" })
101
- ] }) : /* @__PURE__ */ jsx2("div", { className: `prose prose-sm max-w-none ${isUser ? "prose-invert" : "dark:prose-invert"}`, children: /* @__PURE__ */ jsx2(ReactMarkdown, { remarkPlugins: [remarkGfm], children: message.content }) })
102
- }
103
- ),
104
- !isUser && sources && sources.length > 0 && /* @__PURE__ */ jsxs2("div", { className: "w-full", children: [
105
- /* @__PURE__ */ jsxs2(
106
- "button",
107
- {
108
- onClick: () => setShowSources((s) => !s),
109
- className: "text-[11px] text-indigo-400 hover:text-indigo-300 transition-colors flex items-center gap-1 mt-1",
110
- children: [
111
- showSources ? /* @__PURE__ */ jsx2(ChevronDown2, { className: "w-3 h-3" }) : /* @__PURE__ */ jsx2(ChevronRight, { className: "w-3 h-3" }),
112
- sources.length,
113
- " source",
114
- sources.length !== 1 ? "s" : "",
115
- " used"
116
- ]
117
- }
118
- ),
119
- showSources && /* @__PURE__ */ jsx2("div", { className: "mt-2 flex flex-col gap-2", children: sources.map((src, i) => /* @__PURE__ */ jsx2(SourceCard, { source: src, index: i }, src.id)) })
120
- ] })
121
- ] })
122
- ] });
63
+ return /* @__PURE__ */ React2.createElement("div", { className: `flex gap-3 ${isUser ? "flex-row-reverse" : "flex-row"} items-start` }, /* @__PURE__ */ React2.createElement(
64
+ "div",
65
+ {
66
+ className: `flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center shadow-lg ${isUser ? "text-white" : "bg-slate-100 dark:bg-white/10 text-slate-700 dark:text-white/80"}`,
67
+ style: isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {}
68
+ },
69
+ isUser ? /* @__PURE__ */ React2.createElement(User, { className: "w-4 h-4 text-white" }) : /* @__PURE__ */ React2.createElement(Bot, { className: "w-4 h-4" })
70
+ ), /* @__PURE__ */ React2.createElement("div", { className: `flex flex-col gap-1 max-w-[75%] ${isUser ? "items-end" : "items-start"}` }, /* @__PURE__ */ React2.createElement(
71
+ "div",
72
+ {
73
+ className: `relative px-4 py-3 rounded-2xl text-sm leading-relaxed shadow-sm dark:shadow-lg ${isUser ? "text-white rounded-tr-sm" : "bg-white dark:bg-white/5 border border-slate-200 dark:border-white/10 text-slate-800 dark:text-white/90 rounded-tl-sm"}`,
74
+ style: isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {}
75
+ },
76
+ isStreaming ? /* @__PURE__ */ React2.createElement("span", { className: "flex items-center gap-1" }, /* @__PURE__ */ React2.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:0ms]" }), /* @__PURE__ */ React2.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:150ms]" }), /* @__PURE__ */ React2.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:300ms]" })) : /* @__PURE__ */ React2.createElement("div", { className: `prose prose-sm max-w-none ${isUser ? "prose-invert" : "dark:prose-invert"}` }, /* @__PURE__ */ React2.createElement(ReactMarkdown, { remarkPlugins: [remarkGfm] }, message.content))
77
+ ), !isUser && sources && sources.length > 0 && /* @__PURE__ */ React2.createElement("div", { className: "w-full" }, /* @__PURE__ */ React2.createElement(
78
+ "button",
79
+ {
80
+ onClick: () => setShowSources((s) => !s),
81
+ className: "text-[11px] text-indigo-400 hover:text-indigo-300 transition-colors flex items-center gap-1 mt-1"
82
+ },
83
+ showSources ? /* @__PURE__ */ React2.createElement(ChevronDown2, { className: "w-3 h-3" }) : /* @__PURE__ */ React2.createElement(ChevronRight, { className: "w-3 h-3" }),
84
+ sources.length,
85
+ " source",
86
+ sources.length !== 1 ? "s" : "",
87
+ " used"
88
+ ), showSources && /* @__PURE__ */ React2.createElement("div", { className: "mt-2 flex flex-col gap-2" }, sources.map((src, i) => /* @__PURE__ */ React2.createElement(SourceCard, { key: src.id, source: src, index: i }))))));
123
89
  }
124
90
 
125
91
  // src/components/ConfigProvider.tsx
126
- import { createContext, useContext } from "react";
127
- import { jsx as jsx3 } from "react/jsx-runtime";
92
+ import React3, { createContext, useContext } from "react";
128
93
  var defaultConfig = {
129
94
  projectId: "default",
130
95
  ui: {
@@ -152,7 +117,7 @@ function ConfigProvider({
152
117
  projectId: (config == null ? void 0 : config.projectId) || defaultConfig.projectId,
153
118
  ui: mergeDefined(defaultConfig.ui, config == null ? void 0 : config.ui)
154
119
  };
155
- return /* @__PURE__ */ jsx3(ConfigContext.Provider, { value: merged, children });
120
+ return /* @__PURE__ */ React3.createElement(ConfigContext.Provider, { value: merged }, children);
156
121
  }
157
122
  function useConfig() {
158
123
  return useContext(ConfigContext);
@@ -280,6 +245,7 @@ function useRagChat(projectId, options = {}) {
280
245
  }
281
246
 
282
247
  // src/app/constants.tsx
248
+ import React5 from "react";
283
249
  import {
284
250
  Zap,
285
251
  Database,
@@ -299,7 +265,6 @@ import {
299
265
  Puzzle,
300
266
  MessageSquare
301
267
  } from "lucide-react";
302
- import { jsx as jsx4 } from "react/jsx-runtime";
303
268
  var CHAT_SUGGESTIONS = [
304
269
  "What can you help me with?",
305
270
  "Summarise the key topics",
@@ -315,7 +280,6 @@ var BORDER_RADIUS_MAP = {
315
280
  };
316
281
 
317
282
  // src/components/ChatWindow.tsx
318
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
319
283
  function ChatWindow({ className = "", style, onClose, showClose = false }) {
320
284
  const { ui, projectId } = useConfig();
321
285
  const [input, setInput] = useState3("");
@@ -356,158 +320,119 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
356
320
  const isEmpty = messages.length === 0;
357
321
  const currentRadius = BORDER_RADIUS_MAP[ui.borderRadius || "xl"];
358
322
  const isGlass = ui.visualStyle !== "solid";
359
- return /* @__PURE__ */ jsxs3(
323
+ return /* @__PURE__ */ React6.createElement(
360
324
  "div",
361
325
  {
362
326
  className: `flex flex-col border border-slate-200 dark:border-white/10 shadow-2xl transition-all duration-300 ${currentRadius} ${isGlass ? "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl" : "bg-white dark:bg-[#0f0f1a]"} ${className}`,
363
- style: __spreadValues({ "--primary": ui.primaryColor, "--accent": ui.accentColor }, style),
364
- children: [
365
- /* @__PURE__ */ jsxs3(
366
- "div",
327
+ style: __spreadValues({ "--primary": ui.primaryColor, "--accent": ui.accentColor }, style)
328
+ },
329
+ /* @__PURE__ */ React6.createElement(
330
+ "div",
331
+ {
332
+ className: "flex items-center justify-between px-5 py-4 border-b border-slate-200 dark:border-white/10",
333
+ style: { background: `linear-gradient(135deg, ${ui.primaryColor}15, ${ui.accentColor}10)` }
334
+ },
335
+ /* @__PURE__ */ React6.createElement("div", { className: "flex items-center gap-3" }, ui.logoUrl ? (
336
+ // eslint-disable-next-line @next/next/no-img-element
337
+ /* @__PURE__ */ React6.createElement("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" })
338
+ ) : /* @__PURE__ */ React6.createElement(
339
+ "div",
340
+ {
341
+ className: `w-9 h-9 flex items-center justify-center shadow-md ${ui.borderRadius === "full" ? "rounded-full" : "rounded-xl"}`,
342
+ style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
343
+ },
344
+ /* @__PURE__ */ React6.createElement(Bot3, { className: "w-5 h-5 text-white" })
345
+ ), /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight" }, ui.title), ui.poweredBy && /* @__PURE__ */ React6.createElement("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight" }, `Powered by ${ui.poweredBy}`))),
346
+ /* @__PURE__ */ React6.createElement("div", { className: "flex items-center gap-2" }, /* @__PURE__ */ React6.createElement("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400" }, /* @__PURE__ */ React6.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }), "Online"), mounted && messages.length > 0 && /* @__PURE__ */ React6.createElement(
347
+ "button",
348
+ {
349
+ onClick: clearHistory,
350
+ title: "Clear conversation",
351
+ className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer"
352
+ },
353
+ /* @__PURE__ */ React6.createElement(Trash2, { className: "w-3.5 h-3.5" })
354
+ ), showClose && onClose && /* @__PURE__ */ React6.createElement(
355
+ "button",
356
+ {
357
+ onClick: onClose,
358
+ title: "Close chat",
359
+ className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer"
360
+ },
361
+ /* @__PURE__ */ React6.createElement(X, { className: "w-4 h-4" })
362
+ ))
363
+ ),
364
+ /* @__PURE__ */ React6.createElement("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5 scrollbar-thin scrollbar-thumb-slate-200 dark:scrollbar-thumb-white/10 scrollbar-track-transparent min-h-0 bg-slate-50 dark:bg-transparent" }, !mounted || isEmpty ? (
365
+ /* Welcome state */
366
+ /* @__PURE__ */ React6.createElement("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12" }, /* @__PURE__ */ React6.createElement(
367
+ "div",
368
+ {
369
+ className: `w-16 h-16 flex items-center justify-center shadow-lg ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"}`,
370
+ style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
371
+ },
372
+ /* @__PURE__ */ React6.createElement(Sparkles2, { className: "w-8 h-8 text-white" })
373
+ ), /* @__PURE__ */ React6.createElement("div", null, /* @__PURE__ */ React6.createElement("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed" }, ui.welcomeMessage), /* @__PURE__ */ React6.createElement("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2" }, "Ask a question to get started")), /* @__PURE__ */ React6.createElement("div", { className: "flex flex-wrap gap-2 justify-center mt-2" }, CHAT_SUGGESTIONS.map(
374
+ (suggestion) => /* @__PURE__ */ React6.createElement(
375
+ "button",
367
376
  {
368
- className: "flex items-center justify-between px-5 py-4 border-b border-slate-200 dark:border-white/10",
369
- style: { background: `linear-gradient(135deg, ${ui.primaryColor}15, ${ui.accentColor}10)` },
370
- children: [
371
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-3", children: [
372
- ui.logoUrl ? (
373
- // eslint-disable-next-line @next/next/no-img-element
374
- /* @__PURE__ */ jsx5("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" })
375
- ) : /* @__PURE__ */ jsx5(
376
- "div",
377
- {
378
- className: `w-9 h-9 flex items-center justify-center shadow-md ${ui.borderRadius === "full" ? "rounded-full" : "rounded-xl"}`,
379
- style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
380
- children: /* @__PURE__ */ jsx5(Bot3, { className: "w-5 h-5 text-white" })
381
- }
382
- ),
383
- /* @__PURE__ */ jsxs3("div", { children: [
384
- /* @__PURE__ */ jsx5("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight", children: ui.title }),
385
- ui.poweredBy && /* @__PURE__ */ jsx5("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight", children: `Powered by ${ui.poweredBy}` })
386
- ] })
387
- ] }),
388
- /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2", children: [
389
- /* @__PURE__ */ jsxs3("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400", children: [
390
- /* @__PURE__ */ jsx5("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }),
391
- "Online"
392
- ] }),
393
- mounted && messages.length > 0 && /* @__PURE__ */ jsx5(
394
- "button",
395
- {
396
- onClick: clearHistory,
397
- title: "Clear conversation",
398
- className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer",
399
- children: /* @__PURE__ */ jsx5(Trash2, { className: "w-3.5 h-3.5" })
400
- }
401
- ),
402
- showClose && onClose && /* @__PURE__ */ jsx5(
403
- "button",
404
- {
405
- onClick: onClose,
406
- title: "Close chat",
407
- className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer",
408
- children: /* @__PURE__ */ jsx5(X, { className: "w-4 h-4" })
409
- }
410
- )
411
- ] })
412
- ]
413
- }
414
- ),
415
- /* @__PURE__ */ jsxs3("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5 scrollbar-thin scrollbar-thumb-slate-200 dark:scrollbar-thumb-white/10 scrollbar-track-transparent min-h-0 bg-slate-50 dark:bg-transparent", children: [
416
- !mounted || isEmpty ? (
417
- /* Welcome state */
418
- /* @__PURE__ */ jsxs3("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12", children: [
419
- /* @__PURE__ */ jsx5(
420
- "div",
421
- {
422
- className: `w-16 h-16 flex items-center justify-center shadow-lg ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"}`,
423
- style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
424
- children: /* @__PURE__ */ jsx5(Sparkles2, { className: "w-8 h-8 text-white" })
425
- }
426
- ),
427
- /* @__PURE__ */ jsxs3("div", { children: [
428
- /* @__PURE__ */ jsx5("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed", children: ui.welcomeMessage }),
429
- /* @__PURE__ */ jsx5("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2", children: "Ask a question to get started" })
430
- ] }),
431
- /* @__PURE__ */ jsx5("div", { className: "flex flex-wrap gap-2 justify-center mt-2", children: CHAT_SUGGESTIONS.map(
432
- (suggestion) => /* @__PURE__ */ jsx5(
433
- "button",
434
- {
435
- onClick: () => {
436
- var _a;
437
- setInput(suggestion);
438
- (_a = inputRef.current) == null ? void 0 : _a.focus();
439
- },
440
- className: "px-3 py-1.5 rounded-full text-xs border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/50 hover:text-slate-900 dark:hover:text-white/80 hover:border-slate-300 dark:hover:border-white/20 hover:bg-slate-100 dark:hover:bg-white/5 transition-all",
441
- children: suggestion
442
- },
443
- suggestion
444
- )
445
- ) })
446
- ] })
447
- ) : messages.map((msg) => /* @__PURE__ */ jsx5(
448
- MessageBubble,
449
- {
450
- message: msg,
451
- sources: msg.sources,
452
- primaryColor: ui.primaryColor,
453
- accentColor: ui.accentColor
377
+ key: suggestion,
378
+ onClick: () => {
379
+ var _a;
380
+ setInput(suggestion);
381
+ (_a = inputRef.current) == null ? void 0 : _a.focus();
454
382
  },
455
- msg.id
456
- )),
457
- isLoading && /* @__PURE__ */ jsx5(
458
- MessageBubble,
459
- {
460
- message: { role: "assistant", content: "" },
461
- isStreaming: true,
462
- primaryColor: ui.primaryColor,
463
- accentColor: ui.accentColor
464
- }
465
- ),
466
- error && /* @__PURE__ */ jsxs3("div", { className: "flex items-center gap-2 text-rose-500 dark:text-rose-400 text-sm bg-rose-50 dark:bg-rose-400/10 border border-rose-200 dark:border-rose-400/20 rounded-xl px-4 py-3", children: [
467
- /* @__PURE__ */ jsx5(TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }),
468
- /* @__PURE__ */ jsx5("span", { children: error })
469
- ] }),
470
- /* @__PURE__ */ jsx5("div", { ref: bottomRef })
471
- ] }),
472
- /* @__PURE__ */ jsxs3("div", { className: `px-4 pb-4 pt-2 border-t border-slate-200 dark:border-white/10 ${isGlass ? "bg-transparent" : "bg-white dark:bg-[#0f0f1a]"}`, children: [
473
- /* @__PURE__ */ jsxs3("div", { className: `flex items-end gap-2 bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 p-2 focus-within:border-slate-300 dark:focus-within:border-white/20 transition-all ${ui.borderRadius === "full" ? "rounded-3xl" : "rounded-2xl"}`, children: [
474
- /* @__PURE__ */ jsx5(
475
- "textarea",
476
- {
477
- ref: inputRef,
478
- value: input,
479
- onChange: (e) => setInput(e.target.value),
480
- onKeyDown: handleKeyDown,
481
- placeholder: ui.placeholder,
482
- rows: 1,
483
- disabled: isLoading,
484
- className: "flex-1 bg-transparent text-slate-900 dark:text-white/90 placeholder-slate-400 dark:placeholder-white/30 text-sm resize-none outline-none py-1.5 px-2 max-h-32 leading-relaxed disabled:opacity-50",
485
- style: { scrollbarWidth: "none" }
486
- }
487
- ),
488
- /* @__PURE__ */ jsx5(
489
- "button",
490
- {
491
- onClick: sendMessage,
492
- disabled: !input.trim() || isLoading,
493
- className: "flex-shrink-0 w-9 h-9 rounded-xl flex items-center justify-center transition-all disabled:opacity-30 disabled:cursor-not-allowed hover:scale-105 active:scale-95 shadow-md",
494
- style: {
495
- background: input.trim() && !isLoading ? `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` : "rgba(148, 163, 184, 0.2)"
496
- // slate-400/20 for light mode disabled
497
- },
498
- children: /* @__PURE__ */ jsx5(ArrowUp, { className: "w-4 h-4 text-white" })
499
- }
500
- )
501
- ] }),
502
- /* @__PURE__ */ jsx5("p", { className: "text-center text-[10px] text-slate-400 dark:text-white/20 mt-2", children: "Press Enter to send \xB7 Shift+Enter for new line" })
503
- ] })
504
- ]
505
- }
383
+ className: "px-3 py-1.5 rounded-full text-xs border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/50 hover:text-slate-900 dark:hover:text-white/80 hover:border-slate-300 dark:hover:border-white/20 hover:bg-slate-100 dark:hover:bg-white/5 transition-all"
384
+ },
385
+ suggestion
386
+ )
387
+ )))
388
+ ) : messages.map((msg) => /* @__PURE__ */ React6.createElement(
389
+ MessageBubble,
390
+ {
391
+ key: msg.id,
392
+ message: msg,
393
+ sources: msg.sources,
394
+ primaryColor: ui.primaryColor,
395
+ accentColor: ui.accentColor
396
+ }
397
+ )), isLoading && /* @__PURE__ */ React6.createElement(
398
+ MessageBubble,
399
+ {
400
+ message: { role: "assistant", content: "" },
401
+ isStreaming: true,
402
+ primaryColor: ui.primaryColor,
403
+ accentColor: ui.accentColor
404
+ }
405
+ ), error && /* @__PURE__ */ React6.createElement("div", { className: "flex items-center gap-2 text-rose-500 dark:text-rose-400 text-sm bg-rose-50 dark:bg-rose-400/10 border border-rose-200 dark:border-rose-400/20 rounded-xl px-4 py-3" }, /* @__PURE__ */ React6.createElement(TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ React6.createElement("span", null, error)), /* @__PURE__ */ React6.createElement("div", { ref: bottomRef })),
406
+ /* @__PURE__ */ React6.createElement("div", { className: `px-4 pb-4 pt-2 border-t border-slate-200 dark:border-white/10 ${isGlass ? "bg-transparent" : "bg-white dark:bg-[#0f0f1a]"}` }, /* @__PURE__ */ React6.createElement("div", { className: `flex items-end gap-2 bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 p-2 focus-within:border-slate-300 dark:focus-within:border-white/20 transition-all ${ui.borderRadius === "full" ? "rounded-3xl" : "rounded-2xl"}` }, /* @__PURE__ */ React6.createElement(
407
+ "textarea",
408
+ {
409
+ ref: inputRef,
410
+ value: input,
411
+ onChange: (e) => setInput(e.target.value),
412
+ onKeyDown: handleKeyDown,
413
+ placeholder: ui.placeholder,
414
+ rows: 1,
415
+ disabled: isLoading,
416
+ className: "flex-1 bg-transparent text-slate-900 dark:text-white/90 placeholder-slate-400 dark:placeholder-white/30 text-sm resize-none outline-none py-1.5 px-2 max-h-32 leading-relaxed disabled:opacity-50",
417
+ style: { scrollbarWidth: "none" }
418
+ }
419
+ ), /* @__PURE__ */ React6.createElement(
420
+ "button",
421
+ {
422
+ onClick: sendMessage,
423
+ disabled: !input.trim() || isLoading,
424
+ className: "flex-shrink-0 w-9 h-9 rounded-xl flex items-center justify-center transition-all disabled:opacity-30 disabled:cursor-not-allowed hover:scale-105 active:scale-95 shadow-md",
425
+ style: {
426
+ background: input.trim() && !isLoading ? `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` : "rgba(148, 163, 184, 0.2)"
427
+ // slate-400/20 for light mode disabled
428
+ }
429
+ },
430
+ /* @__PURE__ */ React6.createElement(ArrowUp, { className: "w-4 h-4 text-white" })
431
+ )), /* @__PURE__ */ React6.createElement("p", { className: "text-center text-[10px] text-slate-400 dark:text-white/20 mt-2" }, "Press Enter to send \xB7 Shift+Enter for new line"))
506
432
  );
507
433
  }
508
434
 
509
435
  // src/components/ChatWidget.tsx
510
- import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
511
436
  function ChatWidget({ position = "bottom-right" }) {
512
437
  const { ui } = useConfig();
513
438
  const [isOpen, setIsOpen] = useState4(false);
@@ -520,63 +445,55 @@ function ChatWidget({ position = "bottom-right" }) {
520
445
  setIsOpen(true);
521
446
  setHasUnread(false);
522
447
  };
523
- return /* @__PURE__ */ jsxs4(Fragment2, { children: [
524
- /* @__PURE__ */ jsxs4(
525
- "div",
448
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, /* @__PURE__ */ React7.createElement(
449
+ "div",
450
+ {
451
+ className: `fixed z-[9998] w-[380px] max-w-[calc(100vw-3rem)] transition-all duration-300 ease-in-out ${windowPositionClass} ${isOpen ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-4 pointer-events-none"}`,
452
+ style: { height: "600px", maxHeight: "calc(100vh - 6rem)" }
453
+ },
454
+ /* @__PURE__ */ React7.createElement(
455
+ ChatWindow,
526
456
  {
527
- className: `fixed z-[9998] w-[380px] max-w-[calc(100vw-3rem)] transition-all duration-300 ease-in-out ${windowPositionClass} ${isOpen ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-4 pointer-events-none"}`,
528
- style: { height: "600px", maxHeight: "calc(100vh - 6rem)" },
529
- children: [
530
- /* @__PURE__ */ jsx6(
531
- ChatWindow,
532
- {
533
- className: "h-full relative z-10",
534
- showClose: true,
535
- onClose: () => setIsOpen(false)
536
- }
537
- ),
538
- /* @__PURE__ */ jsx6(
539
- "div",
540
- {
541
- className: `absolute -bottom-1.5 w-4 h-4 rotate-45 border-r border-b border-slate-200 dark:border-white/10 z-0 ${ui.visualStyle === "solid" ? "bg-white dark:bg-[#0f0f1a]" : "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl"} ${position === "bottom-left" ? "left-5" : "right-5"}`
542
- }
543
- )
544
- ]
457
+ className: "h-full relative z-10",
458
+ showClose: true,
459
+ onClose: () => setIsOpen(false)
545
460
  }
546
461
  ),
547
- /* @__PURE__ */ jsxs4(
548
- "button",
462
+ /* @__PURE__ */ React7.createElement(
463
+ "div",
549
464
  {
550
- onClick: isOpen ? () => setIsOpen(false) : handleOpen,
551
- className: `fixed z-[9999] w-14 h-14 shadow-2xl flex items-center justify-center transition-all duration-300 cursor-pointer hover:scale-110 active:scale-95 ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"} ${positionClass}`,
552
- style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
553
- "aria-label": "Open chat",
554
- children: [
555
- /* @__PURE__ */ jsx6(
556
- "span",
557
- {
558
- className: "absolute inset-0 rounded-full animate-ping opacity-20",
559
- style: { background: ui.primaryColor }
560
- }
561
- ),
562
- /* @__PURE__ */ jsx6(
563
- "span",
564
- {
565
- className: `transition-transform duration-300 ${isOpen ? "rotate-90 scale-90" : "rotate-0 scale-100"}`,
566
- children: isOpen ? /* @__PURE__ */ jsx6(X2, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ jsx6(MessageSquare2, { className: "w-6 h-6 text-white" })
567
- }
568
- ),
569
- hasUnread && !isOpen && /* @__PURE__ */ jsx6("span", { className: "absolute top-0 right-0 w-4 h-4 bg-rose-500 rounded-full border-2 border-white flex items-center justify-center text-[9px] font-bold text-white", children: "1" })
570
- ]
465
+ className: `absolute -bottom-1.5 w-4 h-4 rotate-45 border-r border-b border-slate-200 dark:border-white/10 z-0 ${ui.visualStyle === "solid" ? "bg-white dark:bg-[#0f0f1a]" : "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl"} ${position === "bottom-left" ? "left-5" : "right-5"}`
571
466
  }
572
467
  )
573
- ] });
468
+ ), /* @__PURE__ */ React7.createElement(
469
+ "button",
470
+ {
471
+ onClick: isOpen ? () => setIsOpen(false) : handleOpen,
472
+ className: `fixed z-[9999] w-14 h-14 shadow-2xl flex items-center justify-center transition-all duration-300 cursor-pointer hover:scale-110 active:scale-95 ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"} ${positionClass}`,
473
+ style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
474
+ "aria-label": "Open chat"
475
+ },
476
+ /* @__PURE__ */ React7.createElement(
477
+ "span",
478
+ {
479
+ className: "absolute inset-0 rounded-full animate-ping opacity-20",
480
+ style: { background: ui.primaryColor }
481
+ }
482
+ ),
483
+ /* @__PURE__ */ React7.createElement(
484
+ "span",
485
+ {
486
+ className: `transition-transform duration-300 ${isOpen ? "rotate-90 scale-90" : "rotate-0 scale-100"}`
487
+ },
488
+ isOpen ? /* @__PURE__ */ React7.createElement(X2, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ React7.createElement(MessageSquare2, { className: "w-6 h-6 text-white" })
489
+ ),
490
+ hasUnread && !isOpen && /* @__PURE__ */ React7.createElement("span", { className: "absolute top-0 right-0 w-4 h-4 bg-rose-500 rounded-full border-2 border-white flex items-center justify-center text-[9px] font-bold text-white" }, "1")
491
+ ));
574
492
  }
575
493
 
576
494
  // src/components/DocumentUpload.tsx
577
- import { useState as useState5, useRef as useRef3 } from "react";
495
+ import React8, { useState as useState5, useRef as useRef3 } from "react";
578
496
  import { Upload, File, X as X3, CheckCircle, AlertCircle, Loader2 } from "lucide-react";
579
- import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
580
497
  function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
581
498
  const { ui } = useConfig();
582
499
  const [fileStates, setFileStates] = useState5([]);
@@ -631,99 +548,72 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
631
548
  };
632
549
  const isUploading = fileStates.some((s) => s.status === "uploading");
633
550
  const hasIdle = fileStates.some((s) => s.status === "idle");
634
- return /* @__PURE__ */ jsxs5(
551
+ return /* @__PURE__ */ React8.createElement(
635
552
  "div",
636
553
  {
637
554
  className: `p-6 border-2 border-dashed transition-all duration-300 rounded-2xl ${isDragging ? "border-emerald-500 bg-emerald-50/50 dark:bg-emerald-500/5" : "border-slate-200 dark:border-white/10 bg-white dark:bg-white/5"} ${className}`,
638
555
  onDragOver,
639
556
  onDragLeave,
640
- onDrop,
641
- children: [
642
- /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center justify-center text-center", children: [
643
- /* @__PURE__ */ jsx7(
644
- "div",
645
- {
646
- className: "w-12 h-12 rounded-full flex items-center justify-center mb-4 shadow-sm",
647
- style: { background: `linear-gradient(135deg, ${ui.primaryColor}20, ${ui.accentColor}20)` },
648
- children: /* @__PURE__ */ jsx7(Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
649
- }
650
- ),
651
- /* @__PURE__ */ jsx7("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1", children: "Upload Documents" }),
652
- /* @__PURE__ */ jsx7("p", { className: "text-slate-500 dark:text-white/40 text-sm mb-6 max-w-xs", children: "Drag and drop PDF, DOCX, TXT, or JSON files to train your AI on your own data." }),
653
- /* @__PURE__ */ jsx7(
654
- "button",
655
- {
656
- onClick: () => {
657
- var _a;
658
- return (_a = fileInputRef.current) == null ? void 0 : _a.click();
659
- },
660
- disabled: isUploading,
661
- className: "px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105 active:scale-95 disabled:opacity-50",
662
- style: {
663
- backgroundColor: `${ui.primaryColor}15`,
664
- color: ui.primaryColor,
665
- border: `1px solid ${ui.primaryColor}30`
666
- },
667
- children: "Select Files"
668
- }
669
- ),
670
- /* @__PURE__ */ jsx7(
671
- "input",
672
- {
673
- ref: fileInputRef,
674
- type: "file",
675
- multiple: true,
676
- onChange: onFileSelect,
677
- className: "hidden",
678
- accept: ".pdf,.docx,.txt,.md,.json,.csv"
679
- }
680
- )
681
- ] }),
682
- fileStates.length > 0 && /* @__PURE__ */ jsxs5("div", { className: "mt-8 space-y-3", children: [
683
- fileStates.map((state, i) => /* @__PURE__ */ jsxs5(
684
- "div",
685
- {
686
- className: "flex items-center justify-between p-3 rounded-xl bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/10",
687
- children: [
688
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-3 overflow-hidden", children: [
689
- /* @__PURE__ */ jsx7("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm", children: /* @__PURE__ */ jsx7(File, { className: "w-4 h-4 text-slate-400" }) }),
690
- /* @__PURE__ */ jsxs5("div", { className: "truncate", children: [
691
- /* @__PURE__ */ jsx7("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate", children: state.file.name }),
692
- /* @__PURE__ */ jsxs5("p", { className: "text-[10px] text-slate-400", children: [
693
- (state.file.size / 1024).toFixed(1),
694
- " KB"
695
- ] })
696
- ] })
697
- ] }),
698
- /* @__PURE__ */ jsxs5("div", { className: "flex items-center gap-2", children: [
699
- state.status === "uploading" && /* @__PURE__ */ jsx7(Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }),
700
- state.status === "success" && /* @__PURE__ */ jsx7(CheckCircle, { className: "w-4 h-4 text-emerald-500" }),
701
- state.status === "error" && /* @__PURE__ */ jsx7("div", { title: state.error, children: /* @__PURE__ */ jsx7(AlertCircle, { className: "w-4 h-4 text-rose-500" }) }),
702
- state.status !== "uploading" && /* @__PURE__ */ jsx7(
703
- "button",
704
- {
705
- onClick: () => removeFile(i),
706
- className: "p-1 rounded-md hover:bg-slate-200 dark:hover:bg-white/10 transition-colors",
707
- children: /* @__PURE__ */ jsx7(X3, { className: "w-3.5 h-3.5 text-slate-400" })
708
- }
709
- )
710
- ] })
711
- ]
712
- },
713
- i
714
- )),
715
- hasIdle && !isUploading && /* @__PURE__ */ jsx7(
716
- "button",
717
- {
718
- onClick: uploadFiles,
719
- className: "w-full mt-4 py-2.5 rounded-xl text-sm font-semibold text-white shadow-lg transition-all hover:scale-[1.02] active:scale-[0.98]",
720
- style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
721
- children: "Start Upload"
722
- }
723
- )
724
- ] })
725
- ]
726
- }
557
+ onDrop
558
+ },
559
+ /* @__PURE__ */ React8.createElement("div", { className: "flex flex-col items-center justify-center text-center" }, /* @__PURE__ */ React8.createElement(
560
+ "div",
561
+ {
562
+ className: "w-12 h-12 rounded-full flex items-center justify-center mb-4 shadow-sm",
563
+ style: { background: `linear-gradient(135deg, ${ui.primaryColor}20, ${ui.accentColor}20)` }
564
+ },
565
+ /* @__PURE__ */ React8.createElement(Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
566
+ ), /* @__PURE__ */ React8.createElement("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1" }, "Upload Documents"), /* @__PURE__ */ React8.createElement("p", { className: "text-slate-500 dark:text-white/40 text-sm mb-6 max-w-xs" }, "Drag and drop PDF, DOCX, TXT, or JSON files to train your AI on your own data."), /* @__PURE__ */ React8.createElement(
567
+ "button",
568
+ {
569
+ onClick: () => {
570
+ var _a;
571
+ return (_a = fileInputRef.current) == null ? void 0 : _a.click();
572
+ },
573
+ disabled: isUploading,
574
+ className: "px-4 py-2 rounded-lg text-sm font-medium transition-all hover:scale-105 active:scale-95 disabled:opacity-50",
575
+ style: {
576
+ backgroundColor: `${ui.primaryColor}15`,
577
+ color: ui.primaryColor,
578
+ border: `1px solid ${ui.primaryColor}30`
579
+ }
580
+ },
581
+ "Select Files"
582
+ ), /* @__PURE__ */ React8.createElement(
583
+ "input",
584
+ {
585
+ ref: fileInputRef,
586
+ type: "file",
587
+ multiple: true,
588
+ onChange: onFileSelect,
589
+ className: "hidden",
590
+ accept: ".pdf,.docx,.txt,.md,.json,.csv"
591
+ }
592
+ )),
593
+ fileStates.length > 0 && /* @__PURE__ */ React8.createElement("div", { className: "mt-8 space-y-3" }, fileStates.map((state, i) => /* @__PURE__ */ React8.createElement(
594
+ "div",
595
+ {
596
+ key: i,
597
+ className: "flex items-center justify-between p-3 rounded-xl bg-slate-50 dark:bg-white/5 border border-slate-100 dark:border-white/10"
598
+ },
599
+ /* @__PURE__ */ React8.createElement("div", { className: "flex items-center gap-3 overflow-hidden" }, /* @__PURE__ */ React8.createElement("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm" }, /* @__PURE__ */ React8.createElement(File, { className: "w-4 h-4 text-slate-400" })), /* @__PURE__ */ React8.createElement("div", { className: "truncate" }, /* @__PURE__ */ React8.createElement("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate" }, state.file.name), /* @__PURE__ */ React8.createElement("p", { className: "text-[10px] text-slate-400" }, (state.file.size / 1024).toFixed(1), " KB"))),
600
+ /* @__PURE__ */ React8.createElement("div", { className: "flex items-center gap-2" }, state.status === "uploading" && /* @__PURE__ */ React8.createElement(Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }), state.status === "success" && /* @__PURE__ */ React8.createElement(CheckCircle, { className: "w-4 h-4 text-emerald-500" }), state.status === "error" && /* @__PURE__ */ React8.createElement("div", { title: state.error }, /* @__PURE__ */ React8.createElement(AlertCircle, { className: "w-4 h-4 text-rose-500" })), state.status !== "uploading" && /* @__PURE__ */ React8.createElement(
601
+ "button",
602
+ {
603
+ onClick: () => removeFile(i),
604
+ className: "p-1 rounded-md hover:bg-slate-200 dark:hover:bg-white/10 transition-colors"
605
+ },
606
+ /* @__PURE__ */ React8.createElement(X3, { className: "w-3.5 h-3.5 text-slate-400" })
607
+ ))
608
+ )), hasIdle && !isUploading && /* @__PURE__ */ React8.createElement(
609
+ "button",
610
+ {
611
+ onClick: uploadFiles,
612
+ className: "w-full mt-4 py-2.5 rounded-xl text-sm font-semibold text-white shadow-lg transition-all hover:scale-[1.02] active:scale-[0.98]",
613
+ style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
614
+ },
615
+ "Start Upload"
616
+ ))
727
617
  );
728
618
  }
729
619
  export {