@retrivora-ai/rag-engine 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +223 -95
- package/dist/index.mjs +199 -71
- package/package.json +1 -1
- package/src/app/globals.css +9 -0
- package/src/components/MessageBubble.tsx +84 -1
- package/src/components/ProductCard.tsx +90 -0
- package/src/components/ProductCarousel.tsx +59 -0
package/dist/index.js
CHANGED
|
@@ -59,16 +59,16 @@ __export(index_exports, {
|
|
|
59
59
|
module.exports = __toCommonJS(index_exports);
|
|
60
60
|
|
|
61
61
|
// src/components/ChatWidget.tsx
|
|
62
|
-
var
|
|
63
|
-
var
|
|
62
|
+
var import_react8 = __toESM(require("react"));
|
|
63
|
+
var import_lucide_react6 = require("lucide-react");
|
|
64
64
|
|
|
65
65
|
// src/components/ChatWindow.tsx
|
|
66
|
-
var
|
|
67
|
-
var
|
|
66
|
+
var import_react7 = __toESM(require("react"));
|
|
67
|
+
var import_lucide_react5 = require("lucide-react");
|
|
68
68
|
|
|
69
69
|
// src/components/MessageBubble.tsx
|
|
70
|
-
var
|
|
71
|
-
var
|
|
70
|
+
var import_react4 = __toESM(require("react"));
|
|
71
|
+
var import_lucide_react4 = require("lucide-react");
|
|
72
72
|
var import_react_markdown = __toESM(require("react-markdown"));
|
|
73
73
|
var import_remark_gfm = __toESM(require("remark-gfm"));
|
|
74
74
|
|
|
@@ -95,6 +95,79 @@ function SourceCard({ source, index }) {
|
|
|
95
95
|
);
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
+
// src/components/ProductCarousel.tsx
|
|
99
|
+
var import_react3 = __toESM(require("react"));
|
|
100
|
+
var import_lucide_react3 = require("lucide-react");
|
|
101
|
+
|
|
102
|
+
// src/components/ProductCard.tsx
|
|
103
|
+
var import_react2 = __toESM(require("react"));
|
|
104
|
+
var import_image = __toESM(require("next/image"));
|
|
105
|
+
var import_lucide_react2 = require("lucide-react");
|
|
106
|
+
function ProductCard({ product, primaryColor = "#6366f1" }) {
|
|
107
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex-shrink-0 w-64 bg-white dark:bg-white/5 border border-slate-200 dark:border-white/10 rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 group" }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "relative h-40 w-full bg-slate-100 dark:bg-white/5 flex items-center justify-center overflow-hidden" }, product.image ? /* @__PURE__ */ import_react2.default.createElement(
|
|
108
|
+
import_image.default,
|
|
109
|
+
{
|
|
110
|
+
src: product.image,
|
|
111
|
+
alt: product.name,
|
|
112
|
+
fill: true,
|
|
113
|
+
unoptimized: true,
|
|
114
|
+
className: "object-cover group-hover:scale-105 transition-transform duration-500"
|
|
115
|
+
}
|
|
116
|
+
) : /* @__PURE__ */ import_react2.default.createElement("div", { className: "text-slate-400 dark:text-white/20" }, /* @__PURE__ */ import_react2.default.createElement(import_lucide_react2.ShoppingCart, { className: "w-12 h-12" })), product.brand && /* @__PURE__ */ import_react2.default.createElement("div", { className: "absolute top-2 left-2 px-2 py-1 bg-white/90 dark:bg-black/60 backdrop-blur-md rounded-md text-[10px] font-bold uppercase tracking-wider text-slate-700 dark:text-white/90 shadow-sm" }, product.brand)), /* @__PURE__ */ import_react2.default.createElement("div", { className: "p-4 flex flex-col gap-2" }, /* @__PURE__ */ import_react2.default.createElement("div", { className: "flex justify-between items-start gap-2" }, /* @__PURE__ */ import_react2.default.createElement("h3", { className: "text-sm font-semibold text-slate-800 dark:text-white/90 line-clamp-1" }, product.name), product.price && /* @__PURE__ */ import_react2.default.createElement("span", { className: "text-sm font-bold", style: { color: primaryColor } }, typeof product.price === "number" ? `$${product.price}` : product.price)), product.description && /* @__PURE__ */ import_react2.default.createElement("p", { className: "text-[11px] text-slate-500 dark:text-white/50 line-clamp-2 leading-relaxed" }, product.description), /* @__PURE__ */ import_react2.default.createElement("div", { className: "mt-2 flex gap-2" }, /* @__PURE__ */ import_react2.default.createElement(
|
|
117
|
+
"button",
|
|
118
|
+
{
|
|
119
|
+
className: "flex-1 py-2 px-3 rounded-lg text-[11px] font-medium text-white shadow-sm hover:opacity-90 transition-opacity flex items-center justify-center gap-1.5",
|
|
120
|
+
style: { background: primaryColor }
|
|
121
|
+
},
|
|
122
|
+
/* @__PURE__ */ import_react2.default.createElement(import_lucide_react2.ShoppingCart, { className: "w-3 h-3" }),
|
|
123
|
+
"Add to Cart"
|
|
124
|
+
), product.link && /* @__PURE__ */ import_react2.default.createElement(
|
|
125
|
+
"a",
|
|
126
|
+
{
|
|
127
|
+
href: product.link,
|
|
128
|
+
target: "_blank",
|
|
129
|
+
rel: "noopener noreferrer",
|
|
130
|
+
className: "p-2 rounded-lg bg-slate-100 dark:bg-white/10 text-slate-600 dark:text-white/70 hover:bg-slate-200 dark:hover:bg-white/20 transition-colors"
|
|
131
|
+
},
|
|
132
|
+
/* @__PURE__ */ import_react2.default.createElement(import_lucide_react2.ExternalLink, { className: "w-3.5 h-3.5" })
|
|
133
|
+
))));
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// src/components/ProductCarousel.tsx
|
|
137
|
+
function ProductCarousel({ products, primaryColor = "#6366f1" }) {
|
|
138
|
+
const scrollRef = (0, import_react3.useRef)(null);
|
|
139
|
+
const scroll = (direction) => {
|
|
140
|
+
if (scrollRef.current) {
|
|
141
|
+
const scrollAmount = direction === "left" ? -280 : 280;
|
|
142
|
+
scrollRef.current.scrollBy({ left: scrollAmount, behavior: "smooth" });
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
if (!products || products.length === 0) return null;
|
|
146
|
+
return /* @__PURE__ */ import_react3.default.createElement("div", { className: "relative w-full my-4 group/carousel" }, /* @__PURE__ */ import_react3.default.createElement("div", { className: "absolute -left-3 top-1/2 -translate-y-1/2 z-10 opacity-0 group-hover/carousel:opacity-100 transition-opacity" }, /* @__PURE__ */ import_react3.default.createElement(
|
|
147
|
+
"button",
|
|
148
|
+
{
|
|
149
|
+
onClick: () => scroll("left"),
|
|
150
|
+
className: "p-1.5 rounded-full bg-white dark:bg-slate-800 shadow-lg border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/80 hover:text-indigo-500 dark:hover:text-indigo-400 transition-colors"
|
|
151
|
+
},
|
|
152
|
+
/* @__PURE__ */ import_react3.default.createElement(import_lucide_react3.ChevronLeft, { className: "w-4 h-4" })
|
|
153
|
+
)), /* @__PURE__ */ import_react3.default.createElement("div", { className: "absolute -right-3 top-1/2 -translate-y-1/2 z-10 opacity-0 group-hover/carousel:opacity-100 transition-opacity" }, /* @__PURE__ */ import_react3.default.createElement(
|
|
154
|
+
"button",
|
|
155
|
+
{
|
|
156
|
+
onClick: () => scroll("right"),
|
|
157
|
+
className: "p-1.5 rounded-full bg-white dark:bg-slate-800 shadow-lg border border-slate-200 dark:border-white/10 text-slate-600 dark:text-white/80 hover:text-indigo-500 dark:hover:text-indigo-400 transition-colors"
|
|
158
|
+
},
|
|
159
|
+
/* @__PURE__ */ import_react3.default.createElement(import_lucide_react3.ChevronRight, { className: "w-4 h-4" })
|
|
160
|
+
)), /* @__PURE__ */ import_react3.default.createElement(
|
|
161
|
+
"div",
|
|
162
|
+
{
|
|
163
|
+
ref: scrollRef,
|
|
164
|
+
className: "flex gap-4 overflow-x-auto pb-4 px-1 scrollbar-hide snap-x snap-mandatory",
|
|
165
|
+
style: { scrollbarWidth: "none", msOverflowStyle: "none" }
|
|
166
|
+
},
|
|
167
|
+
products.map((product) => /* @__PURE__ */ import_react3.default.createElement("div", { key: product.id, className: "snap-start" }, /* @__PURE__ */ import_react3.default.createElement(ProductCard, { product, primaryColor })))
|
|
168
|
+
));
|
|
169
|
+
}
|
|
170
|
+
|
|
98
171
|
// src/components/MessageBubble.tsx
|
|
99
172
|
function MessageBubble({
|
|
100
173
|
message,
|
|
@@ -104,37 +177,92 @@ function MessageBubble({
|
|
|
104
177
|
accentColor = "#8b5cf6"
|
|
105
178
|
}) {
|
|
106
179
|
const isUser = message.role === "user";
|
|
107
|
-
const [showSources, setShowSources] =
|
|
108
|
-
|
|
180
|
+
const [showSources, setShowSources] = import_react4.default.useState(false);
|
|
181
|
+
const resolveImage = (data) => {
|
|
182
|
+
if (!data) return void 0;
|
|
183
|
+
const singleFields = ["image", "img", "thumbnail"];
|
|
184
|
+
for (const field of singleFields) {
|
|
185
|
+
const val = data[field];
|
|
186
|
+
if (typeof val === "string" && val) return val;
|
|
187
|
+
}
|
|
188
|
+
if (Array.isArray(data.images) && data.images.length > 0) {
|
|
189
|
+
if (typeof data.images[0] === "string") return data.images[0];
|
|
190
|
+
}
|
|
191
|
+
return void 0;
|
|
192
|
+
};
|
|
193
|
+
const productsFromSources = import_react4.default.useMemo(() => {
|
|
194
|
+
if (isUser || !sources) return [];
|
|
195
|
+
return sources.filter((s) => {
|
|
196
|
+
const m = s.metadata || {};
|
|
197
|
+
return m.price || m.image || m.img || m.thumbnail || m.images || m.brand || m.type === "product";
|
|
198
|
+
}).map((s) => {
|
|
199
|
+
const m = s.metadata || {};
|
|
200
|
+
return {
|
|
201
|
+
id: s.id,
|
|
202
|
+
name: m.name || m.title || s.content.split("\n")[0] || "Unknown Product",
|
|
203
|
+
brand: m.brand,
|
|
204
|
+
price: m.price,
|
|
205
|
+
image: resolveImage(m),
|
|
206
|
+
link: m.link,
|
|
207
|
+
description: s.content
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
}, [sources, isUser]);
|
|
211
|
+
const { productsFromContent, cleanContent } = import_react4.default.useMemo(() => {
|
|
212
|
+
if (isUser) return { productsFromContent: [], cleanContent: message.content };
|
|
213
|
+
const jsonRegex = /```json\s*([\s\S]*?)\s*```/g;
|
|
214
|
+
const products = [];
|
|
215
|
+
let content = message.content;
|
|
216
|
+
if (content.includes('"type": "products"') || content.includes('"type":"products"')) {
|
|
217
|
+
const matches = Array.from(content.matchAll(jsonRegex));
|
|
218
|
+
for (const m of matches) {
|
|
219
|
+
try {
|
|
220
|
+
const data = JSON.parse(m[1]);
|
|
221
|
+
if (data.type === "products" && Array.isArray(data.items)) {
|
|
222
|
+
const formattedItems = data.items.map((item) => __spreadProps(__spreadValues({}, item), {
|
|
223
|
+
image: item.image || resolveImage(item)
|
|
224
|
+
}));
|
|
225
|
+
products.push(...formattedItems);
|
|
226
|
+
content = content.replace(m[0], "");
|
|
227
|
+
}
|
|
228
|
+
} catch (e) {
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return { productsFromContent: products, cleanContent: content.trim() };
|
|
233
|
+
}, [message.content, isUser]);
|
|
234
|
+
const allProducts = [...productsFromSources, ...productsFromContent];
|
|
235
|
+
const hasProducts = allProducts.length > 0;
|
|
236
|
+
return /* @__PURE__ */ import_react4.default.createElement("div", { className: `flex gap-3 ${isUser ? "flex-row-reverse" : "flex-row"} items-start` }, /* @__PURE__ */ import_react4.default.createElement(
|
|
109
237
|
"div",
|
|
110
238
|
{
|
|
111
239
|
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"}`,
|
|
112
240
|
style: isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {}
|
|
113
241
|
},
|
|
114
|
-
isUser ? /* @__PURE__ */
|
|
115
|
-
), /* @__PURE__ */
|
|
242
|
+
isUser ? /* @__PURE__ */ import_react4.default.createElement(import_lucide_react4.User, { className: "w-4 h-4 text-white" }) : /* @__PURE__ */ import_react4.default.createElement(import_lucide_react4.Bot, { className: "w-4 h-4" })
|
|
243
|
+
), /* @__PURE__ */ import_react4.default.createElement("div", { className: `flex flex-col gap-1 max-w-[75%] ${isUser ? "items-end" : "items-start"}` }, /* @__PURE__ */ import_react4.default.createElement(
|
|
116
244
|
"div",
|
|
117
245
|
{
|
|
118
246
|
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"}`,
|
|
119
247
|
style: isUser ? { background: `linear-gradient(135deg, ${primaryColor}, ${accentColor})` } : {}
|
|
120
248
|
},
|
|
121
|
-
isStreaming && !message.content ? /* @__PURE__ */
|
|
122
|
-
), !isUser && sources && sources.length > 0 && /* @__PURE__ */
|
|
249
|
+
isStreaming && !message.content ? /* @__PURE__ */ import_react4.default.createElement("span", { className: "flex items-center gap-1 py-1" }, /* @__PURE__ */ import_react4.default.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:0ms]" }), /* @__PURE__ */ import_react4.default.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:150ms]" }), /* @__PURE__ */ import_react4.default.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-slate-400 dark:bg-white/60 animate-bounce [animation-delay:300ms]" })) : /* @__PURE__ */ import_react4.default.createElement("div", { className: `prose prose-sm max-w-none ${isUser ? "prose-invert" : "dark:prose-invert"}` }, /* @__PURE__ */ import_react4.default.createElement(import_react_markdown.default, { remarkPlugins: [import_remark_gfm.default] }, cleanContent || message.content), hasProducts && /* @__PURE__ */ import_react4.default.createElement(ProductCarousel, { products: allProducts, primaryColor }), isStreaming && message.content && /* @__PURE__ */ import_react4.default.createElement("span", { className: "inline-block w-1.5 h-3.5 ml-1 bg-emerald-500 animate-pulse align-middle" }))
|
|
250
|
+
), !isUser && sources && sources.length > 0 && /* @__PURE__ */ import_react4.default.createElement("div", { className: "w-full" }, /* @__PURE__ */ import_react4.default.createElement(
|
|
123
251
|
"button",
|
|
124
252
|
{
|
|
125
253
|
onClick: () => setShowSources((s) => !s),
|
|
126
254
|
className: "text-[11px] text-indigo-400 hover:text-indigo-300 transition-colors flex items-center gap-1 mt-1"
|
|
127
255
|
},
|
|
128
|
-
showSources ? /* @__PURE__ */
|
|
256
|
+
showSources ? /* @__PURE__ */ import_react4.default.createElement(import_lucide_react4.ChevronDown, { className: "w-3 h-3" }) : /* @__PURE__ */ import_react4.default.createElement(import_lucide_react4.ChevronRight, { className: "w-3 h-3" }),
|
|
129
257
|
sources.length,
|
|
130
258
|
" source",
|
|
131
259
|
sources.length !== 1 ? "s" : "",
|
|
132
260
|
" used"
|
|
133
|
-
), showSources && /* @__PURE__ */
|
|
261
|
+
), showSources && /* @__PURE__ */ import_react4.default.createElement("div", { className: "mt-2 flex flex-col gap-2" }, sources.map((src, i) => /* @__PURE__ */ import_react4.default.createElement(SourceCard, { key: src.id, source: src, index: i }))))));
|
|
134
262
|
}
|
|
135
263
|
|
|
136
264
|
// src/components/ConfigProvider.tsx
|
|
137
|
-
var
|
|
265
|
+
var import_react5 = __toESM(require("react"));
|
|
138
266
|
|
|
139
267
|
// src/utils/templateUtils.ts
|
|
140
268
|
function mergeDefined(base, override) {
|
|
@@ -170,7 +298,7 @@ var defaultConfig = {
|
|
|
170
298
|
allowResize: true
|
|
171
299
|
}
|
|
172
300
|
};
|
|
173
|
-
var ConfigContext = (0,
|
|
301
|
+
var ConfigContext = (0, import_react5.createContext)(defaultConfig);
|
|
174
302
|
function ConfigProvider({
|
|
175
303
|
config,
|
|
176
304
|
children
|
|
@@ -179,17 +307,17 @@ function ConfigProvider({
|
|
|
179
307
|
projectId: (config == null ? void 0 : config.projectId) || defaultConfig.projectId,
|
|
180
308
|
ui: mergeDefined(defaultConfig.ui, config == null ? void 0 : config.ui)
|
|
181
309
|
};
|
|
182
|
-
return /* @__PURE__ */
|
|
310
|
+
return /* @__PURE__ */ import_react5.default.createElement(ConfigContext.Provider, { value: merged }, children);
|
|
183
311
|
}
|
|
184
312
|
function useConfig() {
|
|
185
|
-
return (0,
|
|
313
|
+
return (0, import_react5.useContext)(ConfigContext);
|
|
186
314
|
}
|
|
187
315
|
|
|
188
316
|
// src/hooks/useRagChat.ts
|
|
189
|
-
var
|
|
317
|
+
var import_react6 = require("react");
|
|
190
318
|
|
|
191
319
|
// src/hooks/useStoredMessages.ts
|
|
192
|
-
var
|
|
320
|
+
var React6 = __toESM(require("react"));
|
|
193
321
|
function readStoredMessages(storageKey) {
|
|
194
322
|
if (typeof window === "undefined") {
|
|
195
323
|
return [];
|
|
@@ -206,8 +334,8 @@ function readStoredMessages(storageKey) {
|
|
|
206
334
|
}
|
|
207
335
|
}
|
|
208
336
|
function useStoredMessages(storageKey, persist) {
|
|
209
|
-
const [messages, setMessages] =
|
|
210
|
-
|
|
337
|
+
const [messages, setMessages] = React6.useState(() => persist ? readStoredMessages(storageKey) : []);
|
|
338
|
+
React6.useEffect(() => {
|
|
211
339
|
if (!persist || typeof window === "undefined") {
|
|
212
340
|
return;
|
|
213
341
|
}
|
|
@@ -247,14 +375,14 @@ function useRagChat(projectId, options = {}) {
|
|
|
247
375
|
} = options;
|
|
248
376
|
const storageKey = `rag_chat_${projectId}`;
|
|
249
377
|
const [messages, setMessages] = useStoredMessages(storageKey, persist);
|
|
250
|
-
const [isLoading, setIsLoading] = (0,
|
|
251
|
-
const [error, setError] = (0,
|
|
252
|
-
const lastInputRef = (0,
|
|
253
|
-
const messagesRef = (0,
|
|
254
|
-
(0,
|
|
378
|
+
const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
|
|
379
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
380
|
+
const lastInputRef = (0, import_react6.useRef)("");
|
|
381
|
+
const messagesRef = (0, import_react6.useRef)(messages);
|
|
382
|
+
(0, import_react6.useEffect)(() => {
|
|
255
383
|
messagesRef.current = messages;
|
|
256
384
|
}, [messages]);
|
|
257
|
-
const sendMessage = (0,
|
|
385
|
+
const sendMessage = (0, import_react6.useCallback)(
|
|
258
386
|
async (text, opts) => {
|
|
259
387
|
var _a, _b;
|
|
260
388
|
const trimmed = text.trim();
|
|
@@ -351,12 +479,12 @@ function useRagChat(projectId, options = {}) {
|
|
|
351
479
|
},
|
|
352
480
|
[apiUrl, isLoading, namespace, onError, onReply, projectId, setMessages]
|
|
353
481
|
);
|
|
354
|
-
const clear = (0,
|
|
482
|
+
const clear = (0, import_react6.useCallback)(() => {
|
|
355
483
|
setMessages([]);
|
|
356
484
|
setError(null);
|
|
357
485
|
if (persist) localStorage.removeItem(storageKey);
|
|
358
486
|
}, [persist, setMessages, storageKey]);
|
|
359
|
-
const retry = (0,
|
|
487
|
+
const retry = (0, import_react6.useCallback)(async () => {
|
|
360
488
|
if (lastInputRef.current) {
|
|
361
489
|
const latestMessage = messagesRef.current[messagesRef.current.length - 1];
|
|
362
490
|
await sendMessage(lastInputRef.current, {
|
|
@@ -404,23 +532,23 @@ function ChatWindow({
|
|
|
404
532
|
}) {
|
|
405
533
|
var _a;
|
|
406
534
|
const { ui, projectId } = useConfig();
|
|
407
|
-
const [input, setInput] = (0,
|
|
408
|
-
const [mounted, setMounted] = (0,
|
|
409
|
-
const bottomRef = (0,
|
|
410
|
-
const inputRef = (0,
|
|
535
|
+
const [input, setInput] = (0, import_react7.useState)("");
|
|
536
|
+
const [mounted, setMounted] = (0, import_react7.useState)(false);
|
|
537
|
+
const bottomRef = (0, import_react7.useRef)(null);
|
|
538
|
+
const inputRef = (0, import_react7.useRef)(null);
|
|
411
539
|
const { messages, send, clear, isLoading, error } = useRagChat(projectId, {
|
|
412
540
|
namespace: projectId
|
|
413
541
|
});
|
|
414
|
-
(0,
|
|
542
|
+
(0, import_react7.useEffect)(() => {
|
|
415
543
|
setMounted(true);
|
|
416
544
|
}, []);
|
|
417
|
-
(0,
|
|
545
|
+
(0, import_react7.useEffect)(() => {
|
|
418
546
|
var _a2;
|
|
419
547
|
if (messages.length > 0 || isLoading) {
|
|
420
548
|
(_a2 = bottomRef.current) == null ? void 0 : _a2.scrollIntoView({ behavior: "smooth" });
|
|
421
549
|
}
|
|
422
550
|
}, [messages, isLoading]);
|
|
423
|
-
const sendMessage = (0,
|
|
551
|
+
const sendMessage = (0, import_react7.useCallback)(async () => {
|
|
424
552
|
const text = input.trim();
|
|
425
553
|
if (!text || isLoading) return;
|
|
426
554
|
setInput("");
|
|
@@ -442,83 +570,83 @@ function ChatWindow({
|
|
|
442
570
|
const isEmpty = messages.length === 0;
|
|
443
571
|
const currentRadius = BORDER_RADIUS_MAP[ui.borderRadius || "xl"];
|
|
444
572
|
const isGlass = ui.visualStyle !== "solid";
|
|
445
|
-
return /* @__PURE__ */
|
|
573
|
+
return /* @__PURE__ */ import_react7.default.createElement(
|
|
446
574
|
"div",
|
|
447
575
|
{
|
|
448
576
|
className: `relative 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}`,
|
|
449
577
|
style: __spreadValues({ "--primary": ui.primaryColor, "--accent": ui.accentColor }, style)
|
|
450
578
|
},
|
|
451
|
-
onResizeStart && /* @__PURE__ */
|
|
579
|
+
onResizeStart && /* @__PURE__ */ import_react7.default.createElement(
|
|
452
580
|
"div",
|
|
453
581
|
{
|
|
454
582
|
onMouseDown: onResizeStart,
|
|
455
583
|
className: "absolute top-0 left-0 w-6 h-6 cursor-nw-resize z-[100] group flex items-start justify-start p-1",
|
|
456
584
|
title: "Drag to resize"
|
|
457
585
|
},
|
|
458
|
-
/* @__PURE__ */
|
|
586
|
+
/* @__PURE__ */ import_react7.default.createElement("div", { className: "w-2.5 h-2.5 border-t-2 border-l-2 border-slate-300 dark:border-white/20 group-hover:border-slate-500 dark:group-hover:border-white/50 transition-colors rounded-tl-[2px]" })
|
|
459
587
|
),
|
|
460
|
-
/* @__PURE__ */
|
|
588
|
+
/* @__PURE__ */ import_react7.default.createElement(
|
|
461
589
|
"div",
|
|
462
590
|
{
|
|
463
591
|
className: "flex items-center justify-between px-5 py-4 border-b border-slate-200 dark:border-white/10",
|
|
464
592
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}15, ${ui.accentColor}10)` }
|
|
465
593
|
},
|
|
466
|
-
/* @__PURE__ */
|
|
594
|
+
/* @__PURE__ */ import_react7.default.createElement("div", { className: "flex items-center gap-3" }, ui.logoUrl ? (
|
|
467
595
|
// eslint-disable-next-line @next/next/no-img-element
|
|
468
|
-
/* @__PURE__ */
|
|
469
|
-
) : /* @__PURE__ */
|
|
596
|
+
/* @__PURE__ */ import_react7.default.createElement("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" })
|
|
597
|
+
) : /* @__PURE__ */ import_react7.default.createElement(
|
|
470
598
|
"div",
|
|
471
599
|
{
|
|
472
600
|
className: `w-9 h-9 flex items-center justify-center shadow-md ${ui.borderRadius === "full" ? "rounded-full" : "rounded-xl"}`,
|
|
473
601
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
|
|
474
602
|
},
|
|
475
|
-
/* @__PURE__ */
|
|
476
|
-
), /* @__PURE__ */
|
|
477
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.Bot, { className: "w-5 h-5 text-white" })
|
|
604
|
+
), /* @__PURE__ */ import_react7.default.createElement("div", null, /* @__PURE__ */ import_react7.default.createElement("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight" }, ui.title), ui.poweredBy && /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight" }, `Powered by ${ui.poweredBy}`))),
|
|
605
|
+
/* @__PURE__ */ import_react7.default.createElement("div", { className: "flex items-center gap-1.5" }, /* @__PURE__ */ import_react7.default.createElement("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400 mr-2" }, /* @__PURE__ */ import_react7.default.createElement("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }), "Online"), /* @__PURE__ */ import_react7.default.createElement("div", { className: "flex items-center bg-slate-100/50 dark:bg-white/5 rounded-lg p-0.5 border border-slate-200/50 dark:border-white/5" }, mounted && messages.length > 0 && /* @__PURE__ */ import_react7.default.createElement(
|
|
478
606
|
"button",
|
|
479
607
|
{
|
|
480
608
|
onClick: clearHistory,
|
|
481
609
|
title: "Clear conversation",
|
|
482
610
|
className: "w-7 h-7 rounded-md flex items-center justify-center text-slate-400 hover:text-rose-500 dark:text-white/40 dark:hover:text-rose-400 hover:bg-white dark:hover:bg-white/10 transition-all cursor-pointer"
|
|
483
611
|
},
|
|
484
|
-
/* @__PURE__ */
|
|
485
|
-
), isResized && onResetResize && /* @__PURE__ */
|
|
612
|
+
/* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.Trash2, { className: "w-3.5 h-3.5" })
|
|
613
|
+
), isResized && onResetResize && /* @__PURE__ */ import_react7.default.createElement(
|
|
486
614
|
"button",
|
|
487
615
|
{
|
|
488
616
|
onClick: onResetResize,
|
|
489
617
|
title: "Reset to default size",
|
|
490
618
|
className: "w-7 h-7 rounded-md flex items-center justify-center text-slate-400 hover:text-blue-500 dark:text-white/40 dark:hover:text-blue-400 hover:bg-white dark:hover:bg-white/10 transition-all cursor-pointer"
|
|
491
619
|
},
|
|
492
|
-
/* @__PURE__ */
|
|
493
|
-
), onMaximize && /* @__PURE__ */
|
|
620
|
+
/* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.RotateCcw, { className: "w-3.5 h-3.5" })
|
|
621
|
+
), onMaximize && /* @__PURE__ */ import_react7.default.createElement(
|
|
494
622
|
"button",
|
|
495
623
|
{
|
|
496
624
|
onClick: onMaximize,
|
|
497
625
|
title: isMaximized ? "Minimize" : "Maximize",
|
|
498
626
|
className: "w-7 h-7 rounded-md flex items-center justify-center text-slate-400 hover:text-blue-500 dark:text-white/40 dark:hover:text-blue-400 hover:bg-white dark:hover:bg-white/10 transition-all cursor-pointer"
|
|
499
627
|
},
|
|
500
|
-
isMaximized ? /* @__PURE__ */
|
|
501
|
-
), showClose && onClose && /* @__PURE__ */
|
|
628
|
+
isMaximized ? /* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.Minimize2, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.Maximize2, { className: "w-3.5 h-3.5" })
|
|
629
|
+
), showClose && onClose && /* @__PURE__ */ import_react7.default.createElement(
|
|
502
630
|
"button",
|
|
503
631
|
{
|
|
504
632
|
onClick: onClose,
|
|
505
633
|
title: "Close chat",
|
|
506
634
|
className: "w-7 h-7 rounded-md flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-white dark:hover:bg-white/10 transition-all cursor-pointer"
|
|
507
635
|
},
|
|
508
|
-
/* @__PURE__ */
|
|
636
|
+
/* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.X, { className: "w-4 h-4" })
|
|
509
637
|
)))
|
|
510
638
|
),
|
|
511
|
-
/* @__PURE__ */
|
|
639
|
+
/* @__PURE__ */ import_react7.default.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 ? (
|
|
512
640
|
/* Welcome state */
|
|
513
|
-
/* @__PURE__ */
|
|
641
|
+
/* @__PURE__ */ import_react7.default.createElement("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12" }, /* @__PURE__ */ import_react7.default.createElement(
|
|
514
642
|
"div",
|
|
515
643
|
{
|
|
516
644
|
className: `w-16 h-16 flex items-center justify-center shadow-lg ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"}`,
|
|
517
645
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` }
|
|
518
646
|
},
|
|
519
|
-
/* @__PURE__ */
|
|
520
|
-
), /* @__PURE__ */
|
|
521
|
-
(suggestion) => /* @__PURE__ */
|
|
647
|
+
/* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.Sparkles, { className: "w-8 h-8 text-white" })
|
|
648
|
+
), /* @__PURE__ */ import_react7.default.createElement("div", null, /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed" }, ui.welcomeMessage), /* @__PURE__ */ import_react7.default.createElement("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2" }, "Ask a question to get started")), /* @__PURE__ */ import_react7.default.createElement("div", { className: "flex flex-wrap gap-2 justify-center mt-2" }, CHAT_SUGGESTIONS.map(
|
|
649
|
+
(suggestion) => /* @__PURE__ */ import_react7.default.createElement(
|
|
522
650
|
"button",
|
|
523
651
|
{
|
|
524
652
|
key: suggestion,
|
|
@@ -532,7 +660,7 @@ function ChatWindow({
|
|
|
532
660
|
suggestion
|
|
533
661
|
)
|
|
534
662
|
)))
|
|
535
|
-
) : messages.map((msg, index) => /* @__PURE__ */
|
|
663
|
+
) : messages.map((msg, index) => /* @__PURE__ */ import_react7.default.createElement(
|
|
536
664
|
MessageBubble,
|
|
537
665
|
{
|
|
538
666
|
key: msg.id,
|
|
@@ -542,7 +670,7 @@ function ChatWindow({
|
|
|
542
670
|
primaryColor: ui.primaryColor,
|
|
543
671
|
accentColor: ui.accentColor
|
|
544
672
|
}
|
|
545
|
-
)), isLoading && ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) !== "assistant" && /* @__PURE__ */
|
|
673
|
+
)), isLoading && ((_a = messages[messages.length - 1]) == null ? void 0 : _a.role) !== "assistant" && /* @__PURE__ */ import_react7.default.createElement(
|
|
546
674
|
MessageBubble,
|
|
547
675
|
{
|
|
548
676
|
message: { role: "assistant", content: "" },
|
|
@@ -550,8 +678,8 @@ function ChatWindow({
|
|
|
550
678
|
primaryColor: ui.primaryColor,
|
|
551
679
|
accentColor: ui.accentColor
|
|
552
680
|
}
|
|
553
|
-
), error && /* @__PURE__ */
|
|
554
|
-
/* @__PURE__ */
|
|
681
|
+
), error && /* @__PURE__ */ import_react7.default.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__ */ import_react7.default.createElement(import_lucide_react5.TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ import_react7.default.createElement("span", null, error)), /* @__PURE__ */ import_react7.default.createElement("div", { ref: bottomRef })),
|
|
682
|
+
/* @__PURE__ */ import_react7.default.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__ */ import_react7.default.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__ */ import_react7.default.createElement(
|
|
555
683
|
"textarea",
|
|
556
684
|
{
|
|
557
685
|
ref: inputRef,
|
|
@@ -564,7 +692,7 @@ function ChatWindow({
|
|
|
564
692
|
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",
|
|
565
693
|
style: { scrollbarWidth: "none" }
|
|
566
694
|
}
|
|
567
|
-
), /* @__PURE__ */
|
|
695
|
+
), /* @__PURE__ */ import_react7.default.createElement(
|
|
568
696
|
"button",
|
|
569
697
|
{
|
|
570
698
|
onClick: sendMessage,
|
|
@@ -575,8 +703,8 @@ function ChatWindow({
|
|
|
575
703
|
// slate-400/20 for light mode disabled
|
|
576
704
|
}
|
|
577
705
|
},
|
|
578
|
-
/* @__PURE__ */
|
|
579
|
-
)), /* @__PURE__ */
|
|
706
|
+
/* @__PURE__ */ import_react7.default.createElement(import_lucide_react5.ArrowUp, { className: "w-4 h-4 text-white" })
|
|
707
|
+
)), /* @__PURE__ */ import_react7.default.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"))
|
|
580
708
|
);
|
|
581
709
|
}
|
|
582
710
|
|
|
@@ -584,12 +712,12 @@ function ChatWindow({
|
|
|
584
712
|
var DEFAULT_DIMENSIONS = { width: 380, height: 600 };
|
|
585
713
|
function ChatWidget({ position = "bottom-right" }) {
|
|
586
714
|
const { ui } = useConfig();
|
|
587
|
-
const [isOpen, setIsOpen] = (0,
|
|
588
|
-
const [hasUnread, setHasUnread] = (0,
|
|
589
|
-
const [dimensions, setDimensions] = (0,
|
|
590
|
-
const [isResizing, setIsResizing] = (0,
|
|
591
|
-
const [isMaximized, setIsMaximized] = (0,
|
|
592
|
-
const [prevDimensions, setPrevDimensions] = (0,
|
|
715
|
+
const [isOpen, setIsOpen] = (0, import_react8.useState)(false);
|
|
716
|
+
const [hasUnread, setHasUnread] = (0, import_react8.useState)(false);
|
|
717
|
+
const [dimensions, setDimensions] = (0, import_react8.useState)(DEFAULT_DIMENSIONS);
|
|
718
|
+
const [isResizing, setIsResizing] = (0, import_react8.useState)(false);
|
|
719
|
+
const [isMaximized, setIsMaximized] = (0, import_react8.useState)(false);
|
|
720
|
+
const [prevDimensions, setPrevDimensions] = (0, import_react8.useState)(DEFAULT_DIMENSIONS);
|
|
593
721
|
if (ui.showWidget === false) return null;
|
|
594
722
|
const positionClass = position === "bottom-left" ? "bottom-6 left-6" : "bottom-6 right-6";
|
|
595
723
|
const windowPositionClass = position === "bottom-left" ? "bottom-20 left-6" : "bottom-20 right-6";
|
|
@@ -639,7 +767,7 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
639
767
|
}
|
|
640
768
|
};
|
|
641
769
|
const isResized = dimensions.width !== DEFAULT_DIMENSIONS.width || dimensions.height !== DEFAULT_DIMENSIONS.height;
|
|
642
|
-
return /* @__PURE__ */
|
|
770
|
+
return /* @__PURE__ */ import_react8.default.createElement(import_react8.default.Fragment, null, /* @__PURE__ */ import_react8.default.createElement(
|
|
643
771
|
"div",
|
|
644
772
|
{
|
|
645
773
|
className: `fixed z-[9998] max-w-[calc(100vw-3rem)] ease-in-out ${windowPositionClass} ${isOpen ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-4 pointer-events-none"} ${isResizing ? "" : "transition-all duration-300"}`,
|
|
@@ -649,7 +777,7 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
649
777
|
maxHeight: "calc(100vh - 6rem)"
|
|
650
778
|
}
|
|
651
779
|
},
|
|
652
|
-
/* @__PURE__ */
|
|
780
|
+
/* @__PURE__ */ import_react8.default.createElement(
|
|
653
781
|
ChatWindow,
|
|
654
782
|
{
|
|
655
783
|
className: "h-full relative z-10",
|
|
@@ -662,13 +790,13 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
662
790
|
isMaximized
|
|
663
791
|
}
|
|
664
792
|
),
|
|
665
|
-
/* @__PURE__ */
|
|
793
|
+
/* @__PURE__ */ import_react8.default.createElement(
|
|
666
794
|
"div",
|
|
667
795
|
{
|
|
668
796
|
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"}`
|
|
669
797
|
}
|
|
670
798
|
)
|
|
671
|
-
), /* @__PURE__ */
|
|
799
|
+
), /* @__PURE__ */ import_react8.default.createElement(
|
|
672
800
|
"button",
|
|
673
801
|
{
|
|
674
802
|
onClick: isOpen ? () => setIsOpen(false) : handleOpen,
|
|
@@ -676,32 +804,32 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
676
804
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
677
805
|
"aria-label": "Open chat"
|
|
678
806
|
},
|
|
679
|
-
/* @__PURE__ */
|
|
807
|
+
/* @__PURE__ */ import_react8.default.createElement(
|
|
680
808
|
"span",
|
|
681
809
|
{
|
|
682
810
|
className: "absolute inset-0 rounded-full animate-ping opacity-20",
|
|
683
811
|
style: { background: ui.primaryColor }
|
|
684
812
|
}
|
|
685
813
|
),
|
|
686
|
-
/* @__PURE__ */
|
|
814
|
+
/* @__PURE__ */ import_react8.default.createElement(
|
|
687
815
|
"span",
|
|
688
816
|
{
|
|
689
817
|
className: `transition-transform duration-300 ${isOpen ? "rotate-90 scale-90" : "rotate-0 scale-100"}`
|
|
690
818
|
},
|
|
691
|
-
isOpen ? /* @__PURE__ */
|
|
819
|
+
isOpen ? /* @__PURE__ */ import_react8.default.createElement(import_lucide_react6.X, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ import_react8.default.createElement(import_lucide_react6.MessageSquare, { className: "w-6 h-6 text-white" })
|
|
692
820
|
),
|
|
693
|
-
hasUnread && !isOpen && /* @__PURE__ */
|
|
821
|
+
hasUnread && !isOpen && /* @__PURE__ */ import_react8.default.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")
|
|
694
822
|
));
|
|
695
823
|
}
|
|
696
824
|
|
|
697
825
|
// src/components/DocumentUpload.tsx
|
|
698
|
-
var
|
|
699
|
-
var
|
|
826
|
+
var import_react9 = __toESM(require("react"));
|
|
827
|
+
var import_lucide_react7 = require("lucide-react");
|
|
700
828
|
function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
701
829
|
const { ui } = useConfig();
|
|
702
|
-
const [fileStates, setFileStates] = (0,
|
|
703
|
-
const [isDragging, setIsDragging] = (0,
|
|
704
|
-
const fileInputRef = (0,
|
|
830
|
+
const [fileStates, setFileStates] = (0, import_react9.useState)([]);
|
|
831
|
+
const [isDragging, setIsDragging] = (0, import_react9.useState)(false);
|
|
832
|
+
const fileInputRef = (0, import_react9.useRef)(null);
|
|
705
833
|
const addFiles = (files) => {
|
|
706
834
|
const newStates = files.map((file) => ({ file, status: "idle" }));
|
|
707
835
|
setFileStates((prev) => [...prev, ...newStates]);
|
|
@@ -751,7 +879,7 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
751
879
|
};
|
|
752
880
|
const isUploading = fileStates.some((s) => s.status === "uploading");
|
|
753
881
|
const hasIdle = fileStates.some((s) => s.status === "idle");
|
|
754
|
-
return /* @__PURE__ */
|
|
882
|
+
return /* @__PURE__ */ import_react9.default.createElement(
|
|
755
883
|
"div",
|
|
756
884
|
{
|
|
757
885
|
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}`,
|
|
@@ -759,14 +887,14 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
759
887
|
onDragLeave,
|
|
760
888
|
onDrop
|
|
761
889
|
},
|
|
762
|
-
/* @__PURE__ */
|
|
890
|
+
/* @__PURE__ */ import_react9.default.createElement("div", { className: "flex flex-col items-center justify-center text-center" }, /* @__PURE__ */ import_react9.default.createElement(
|
|
763
891
|
"div",
|
|
764
892
|
{
|
|
765
893
|
className: "w-12 h-12 rounded-full flex items-center justify-center mb-4 shadow-sm",
|
|
766
894
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}20, ${ui.accentColor}20)` }
|
|
767
895
|
},
|
|
768
|
-
/* @__PURE__ */
|
|
769
|
-
), /* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ import_react9.default.createElement(import_lucide_react7.Upload, { className: "w-6 h-6", style: { color: ui.primaryColor } })
|
|
897
|
+
), /* @__PURE__ */ import_react9.default.createElement("h3", { className: "text-slate-900 dark:text-white font-semibold mb-1" }, "Upload Documents"), /* @__PURE__ */ import_react9.default.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__ */ import_react9.default.createElement(
|
|
770
898
|
"button",
|
|
771
899
|
{
|
|
772
900
|
onClick: () => {
|
|
@@ -782,7 +910,7 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
782
910
|
}
|
|
783
911
|
},
|
|
784
912
|
"Select Files"
|
|
785
|
-
), /* @__PURE__ */
|
|
913
|
+
), /* @__PURE__ */ import_react9.default.createElement(
|
|
786
914
|
"input",
|
|
787
915
|
{
|
|
788
916
|
ref: fileInputRef,
|
|
@@ -793,22 +921,22 @@ function DocumentUpload({ namespace, onUploadComplete, className = "" }) {
|
|
|
793
921
|
accept: ".pdf,.docx,.txt,.md,.json,.csv"
|
|
794
922
|
}
|
|
795
923
|
)),
|
|
796
|
-
fileStates.length > 0 && /* @__PURE__ */
|
|
924
|
+
fileStates.length > 0 && /* @__PURE__ */ import_react9.default.createElement("div", { className: "mt-8 space-y-3" }, fileStates.map((state, i) => /* @__PURE__ */ import_react9.default.createElement(
|
|
797
925
|
"div",
|
|
798
926
|
{
|
|
799
927
|
key: i,
|
|
800
928
|
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"
|
|
801
929
|
},
|
|
802
|
-
/* @__PURE__ */
|
|
803
|
-
/* @__PURE__ */
|
|
930
|
+
/* @__PURE__ */ import_react9.default.createElement("div", { className: "flex items-center gap-3 overflow-hidden" }, /* @__PURE__ */ import_react9.default.createElement("div", { className: "w-8 h-8 rounded-lg bg-white dark:bg-white/10 flex items-center justify-center shadow-sm" }, /* @__PURE__ */ import_react9.default.createElement(import_lucide_react7.File, { className: "w-4 h-4 text-slate-400" })), /* @__PURE__ */ import_react9.default.createElement("div", { className: "truncate" }, /* @__PURE__ */ import_react9.default.createElement("p", { className: "text-xs font-medium text-slate-700 dark:text-white/80 truncate" }, state.file.name), /* @__PURE__ */ import_react9.default.createElement("p", { className: "text-[10px] text-slate-400" }, (state.file.size / 1024).toFixed(1), " KB"))),
|
|
931
|
+
/* @__PURE__ */ import_react9.default.createElement("div", { className: "flex items-center gap-2" }, state.status === "uploading" && /* @__PURE__ */ import_react9.default.createElement(import_lucide_react7.Loader2, { className: "w-4 h-4 text-slate-400 animate-spin" }), state.status === "success" && /* @__PURE__ */ import_react9.default.createElement(import_lucide_react7.CheckCircle, { className: "w-4 h-4 text-emerald-500" }), state.status === "error" && /* @__PURE__ */ import_react9.default.createElement("div", { title: state.error }, /* @__PURE__ */ import_react9.default.createElement(import_lucide_react7.AlertCircle, { className: "w-4 h-4 text-rose-500" })), state.status !== "uploading" && /* @__PURE__ */ import_react9.default.createElement(
|
|
804
932
|
"button",
|
|
805
933
|
{
|
|
806
934
|
onClick: () => removeFile(i),
|
|
807
935
|
className: "p-1 rounded-md hover:bg-slate-200 dark:hover:bg-white/10 transition-colors"
|
|
808
936
|
},
|
|
809
|
-
/* @__PURE__ */
|
|
937
|
+
/* @__PURE__ */ import_react9.default.createElement(import_lucide_react7.X, { className: "w-3.5 h-3.5 text-slate-400" })
|
|
810
938
|
))
|
|
811
|
-
)), hasIdle && !isUploading && /* @__PURE__ */
|
|
939
|
+
)), hasIdle && !isUploading && /* @__PURE__ */ import_react9.default.createElement(
|
|
812
940
|
"button",
|
|
813
941
|
{
|
|
814
942
|
onClick: uploadFiles,
|