fi-glass 1.1.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/LICENSE +77 -0
- package/README.md +162 -0
- package/dist/agent/index.d.ts +399 -0
- package/dist/agent/index.js +1979 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/composer/index.d.ts +57 -0
- package/dist/composer/index.js +112 -0
- package/dist/composer/index.js.map +1 -0
- package/dist/conversation/index.d.ts +80 -0
- package/dist/conversation/index.js +207 -0
- package/dist/conversation/index.js.map +1 -0
- package/dist/glass-theme-D-leVuKb.d.ts +19 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +4316 -0
- package/dist/index.js.map +1 -0
- package/dist/messages/index.d.ts +213 -0
- package/dist/messages/index.js +337 -0
- package/dist/messages/index.js.map +1 -0
- package/dist/persona-selector/index.d.ts +54 -0
- package/dist/persona-selector/index.js +215 -0
- package/dist/persona-selector/index.js.map +1 -0
- package/dist/shell/index.d.ts +429 -0
- package/dist/shell/index.js +1566 -0
- package/dist/shell/index.js.map +1 -0
- package/dist/theme/index.d.ts +58 -0
- package/dist/theme/index.js +38 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/voice/index.d.ts +790 -0
- package/dist/voice/index.js +2591 -0
- package/dist/voice/index.js.map +1 -0
- package/package.json +85 -0
- package/src/theme/glass-chat-preset.ts +74 -0
- package/src/theme/glass-chat.css +217 -0
- package/src/theme/glass-theme.ts +26 -0
- package/src/theme/glass.css +27 -0
- package/src/theme/index.css +3 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/tokens.css +13 -0
|
@@ -0,0 +1,1566 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
// src/shell/ChatWidget.tsx
|
|
4
|
+
import { useCallback as useCallback8 } from "react";
|
|
5
|
+
|
|
6
|
+
// src/shell/useChatWidgetState.ts
|
|
7
|
+
import { useState, useCallback } from "react";
|
|
8
|
+
function useChatWidgetState({
|
|
9
|
+
initialOpen,
|
|
10
|
+
initialMode
|
|
11
|
+
}) {
|
|
12
|
+
const [isOpen, setIsOpen] = useState(initialOpen);
|
|
13
|
+
const [viewMode, setViewMode] = useState(initialMode);
|
|
14
|
+
const [isHistoryOpen, setIsHistoryOpen] = useState(false);
|
|
15
|
+
const [conversationStarted, setConversationStarted] = useState(false);
|
|
16
|
+
const [isStartingConversation, _setIsStartingConversation] = useState(false);
|
|
17
|
+
const open = useCallback(() => {
|
|
18
|
+
setIsOpen(true);
|
|
19
|
+
}, []);
|
|
20
|
+
const close = useCallback(() => {
|
|
21
|
+
setIsOpen(false);
|
|
22
|
+
setViewMode("normal");
|
|
23
|
+
}, []);
|
|
24
|
+
const minimize = useCallback(() => {
|
|
25
|
+
if (viewMode === "expanded") {
|
|
26
|
+
setViewMode("normal");
|
|
27
|
+
}
|
|
28
|
+
}, [viewMode]);
|
|
29
|
+
const maximize = useCallback(() => {
|
|
30
|
+
setViewMode(viewMode === "expanded" ? "normal" : "expanded");
|
|
31
|
+
}, [viewMode]);
|
|
32
|
+
const toggleDenseMode = useCallback(() => {
|
|
33
|
+
setViewMode(viewMode === "dense" ? "fullscreen" : "dense");
|
|
34
|
+
}, [viewMode]);
|
|
35
|
+
const openHistory = useCallback(() => {
|
|
36
|
+
setIsHistoryOpen(true);
|
|
37
|
+
}, []);
|
|
38
|
+
const closeHistory = useCallback(() => {
|
|
39
|
+
setIsHistoryOpen(false);
|
|
40
|
+
}, []);
|
|
41
|
+
const startConversation = useCallback(() => {
|
|
42
|
+
setConversationStarted(true);
|
|
43
|
+
}, []);
|
|
44
|
+
const onMessagesLoaded = useCallback((hasMessages) => {
|
|
45
|
+
if (hasMessages) {
|
|
46
|
+
setConversationStarted(true);
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
return {
|
|
50
|
+
isOpen,
|
|
51
|
+
viewMode,
|
|
52
|
+
isHistoryOpen,
|
|
53
|
+
conversationStarted,
|
|
54
|
+
isStartingConversation,
|
|
55
|
+
open,
|
|
56
|
+
close,
|
|
57
|
+
setViewMode,
|
|
58
|
+
minimize,
|
|
59
|
+
maximize,
|
|
60
|
+
toggleDenseMode,
|
|
61
|
+
openHistory,
|
|
62
|
+
closeHistory,
|
|
63
|
+
startConversation,
|
|
64
|
+
onMessagesLoaded
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/shell/useMediaQuery.ts
|
|
69
|
+
import { useSyncExternalStore } from "react";
|
|
70
|
+
var mqlCache = /* @__PURE__ */ new Map();
|
|
71
|
+
function getMql(query, useCache = true) {
|
|
72
|
+
if (typeof window === "undefined" || !("matchMedia" in window)) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
if (useCache) {
|
|
76
|
+
const cached = mqlCache.get(query);
|
|
77
|
+
if (cached) return cached;
|
|
78
|
+
}
|
|
79
|
+
const mql = window.matchMedia(query);
|
|
80
|
+
if (useCache) {
|
|
81
|
+
mqlCache.set(query, mql);
|
|
82
|
+
}
|
|
83
|
+
return mql;
|
|
84
|
+
}
|
|
85
|
+
function useMediaQuery(query, options) {
|
|
86
|
+
const ssrMatch = options?.ssrMatch ?? false;
|
|
87
|
+
const useRaf = options?.useRaf ?? true;
|
|
88
|
+
const cache = options?.cache ?? true;
|
|
89
|
+
const mql = getMql(query, cache);
|
|
90
|
+
const getSnapshot = () => mql ? mql.matches : ssrMatch;
|
|
91
|
+
const getServerSnapshot = () => ssrMatch;
|
|
92
|
+
const subscribe = (onStoreChange) => {
|
|
93
|
+
if (!mql) return () => {
|
|
94
|
+
};
|
|
95
|
+
let rafId = 0;
|
|
96
|
+
const handler = () => {
|
|
97
|
+
if (!useRaf) {
|
|
98
|
+
onStoreChange();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
102
|
+
rafId = requestAnimationFrame(() => onStoreChange());
|
|
103
|
+
};
|
|
104
|
+
const mqlAny = mql;
|
|
105
|
+
if (typeof mqlAny.addEventListener === "function") {
|
|
106
|
+
mqlAny.addEventListener("change", handler);
|
|
107
|
+
} else if (typeof mqlAny.addListener === "function") {
|
|
108
|
+
mqlAny.addListener(handler);
|
|
109
|
+
}
|
|
110
|
+
return () => {
|
|
111
|
+
if (rafId) cancelAnimationFrame(rafId);
|
|
112
|
+
if (typeof mqlAny.removeEventListener === "function") {
|
|
113
|
+
mqlAny.removeEventListener("change", handler);
|
|
114
|
+
} else if (typeof mqlAny.removeListener === "function") {
|
|
115
|
+
mqlAny.removeListener(handler);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
120
|
+
}
|
|
121
|
+
function useBreakpoints(breakpoints, options) {
|
|
122
|
+
const isMobile = useMediaQuery(breakpoints.mobile, { ssrMatch: options?.ssrMatch });
|
|
123
|
+
const isTablet = useMediaQuery(breakpoints.tablet, { ssrMatch: options?.ssrMatch });
|
|
124
|
+
const isDesktop = useMediaQuery(breakpoints.desktop, { ssrMatch: options?.ssrMatch });
|
|
125
|
+
return { isMobile, isTablet, isDesktop };
|
|
126
|
+
}
|
|
127
|
+
function clearMediaQueryCache() {
|
|
128
|
+
mqlCache.clear();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/shell/config.ts
|
|
132
|
+
var defaultTheme = {
|
|
133
|
+
background: {
|
|
134
|
+
header: "bg-gradient-to-r from-emerald-600 to-cyan-600",
|
|
135
|
+
body: "bg-slate-950",
|
|
136
|
+
input: "bg-slate-800"
|
|
137
|
+
},
|
|
138
|
+
border: {
|
|
139
|
+
main: "border-slate-700",
|
|
140
|
+
input: "border-slate-700",
|
|
141
|
+
bubble: "border-slate-600/60"
|
|
142
|
+
},
|
|
143
|
+
text: {
|
|
144
|
+
primary: "text-white",
|
|
145
|
+
secondary: "text-slate-200",
|
|
146
|
+
muted: "text-slate-400",
|
|
147
|
+
accent: "text-emerald-300"
|
|
148
|
+
},
|
|
149
|
+
accent: { from: "from-emerald-600", to: "to-cyan-600" },
|
|
150
|
+
shadow: "shadow-2xl",
|
|
151
|
+
timestamp: {
|
|
152
|
+
text: "text-slate-400/70",
|
|
153
|
+
tooltip: "bg-slate-800/95 text-slate-200"
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
var defaultBehavior = {
|
|
157
|
+
autoScroll: true,
|
|
158
|
+
showTyping: true,
|
|
159
|
+
groupMessages: true,
|
|
160
|
+
groupThresholdMinutes: 2,
|
|
161
|
+
showDayDividers: true,
|
|
162
|
+
animateEntrance: true,
|
|
163
|
+
maxMessages: 100,
|
|
164
|
+
inputPlaceholder: "Escribe tu mensaje...",
|
|
165
|
+
enableReactions: false,
|
|
166
|
+
enableReadReceipts: false,
|
|
167
|
+
enableThinking: true,
|
|
168
|
+
showThinking: true
|
|
169
|
+
};
|
|
170
|
+
var defaultTimestampConfig = {
|
|
171
|
+
show: true,
|
|
172
|
+
format: "smart",
|
|
173
|
+
showTooltip: true,
|
|
174
|
+
relativeThreshold: 60,
|
|
175
|
+
showSeconds: false,
|
|
176
|
+
position: "inline",
|
|
177
|
+
updateInterval: 6e4
|
|
178
|
+
};
|
|
179
|
+
var defaultAnimationConfig = {
|
|
180
|
+
entrance: { enabled: true, duration: "0.4s", easing: "ease-out" },
|
|
181
|
+
typing: { dotDuration: "1.4s", dotDelay: "0.2s" },
|
|
182
|
+
scroll: { behavior: "smooth", duration: 300 }
|
|
183
|
+
};
|
|
184
|
+
var defaultChatConfig = {
|
|
185
|
+
title: "Free Intelligence",
|
|
186
|
+
subtitle: void 0,
|
|
187
|
+
theme: defaultTheme,
|
|
188
|
+
behavior: defaultBehavior,
|
|
189
|
+
timestamp: defaultTimestampConfig,
|
|
190
|
+
animation: defaultAnimationConfig,
|
|
191
|
+
footer: void 0,
|
|
192
|
+
dimensions: { width: "24rem", height: "600px", minHeight: "400px", maxHeight: "80vh" }
|
|
193
|
+
};
|
|
194
|
+
function mergeChatConfig(custom) {
|
|
195
|
+
if (!custom) return defaultChatConfig;
|
|
196
|
+
return {
|
|
197
|
+
...defaultChatConfig,
|
|
198
|
+
...custom,
|
|
199
|
+
theme: { ...defaultChatConfig.theme, ...custom.theme },
|
|
200
|
+
behavior: { ...defaultChatConfig.behavior, ...custom.behavior },
|
|
201
|
+
timestamp: { ...defaultChatConfig.timestamp, ...custom.timestamp },
|
|
202
|
+
animation: { ...defaultChatConfig.animation, ...custom.animation }
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
var CHAT_BREAKPOINTS = {
|
|
206
|
+
mobile: "(max-width: 639.98px)",
|
|
207
|
+
tablet: "(min-width: 640px) and (max-width: 1023.98px)",
|
|
208
|
+
desktop: "(min-width: 1024px)"
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/shell/FloatingButton.tsx
|
|
212
|
+
import { MessageCircle } from "lucide-react";
|
|
213
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
214
|
+
function FloatingButton({ onClick, isMobile }) {
|
|
215
|
+
const buttonSize = isMobile ? "w-16 h-16" : "w-14 h-14";
|
|
216
|
+
const iconSize = isMobile ? "h-7 w-7" : "h-6 w-6";
|
|
217
|
+
const buttonPosition = isMobile ? "bottom-4 right-4" : "bottom-6 right-6";
|
|
218
|
+
return /* @__PURE__ */ jsxs(
|
|
219
|
+
"button",
|
|
220
|
+
{
|
|
221
|
+
onClick,
|
|
222
|
+
className: `
|
|
223
|
+
fixed ${buttonPosition} ${buttonSize}
|
|
224
|
+
fi-fab-emerald z-50 group
|
|
225
|
+
`,
|
|
226
|
+
"aria-label": "Chat with Free Intelligence",
|
|
227
|
+
children: [
|
|
228
|
+
/* @__PURE__ */ jsx(MessageCircle, { className: `${iconSize} text-white` }),
|
|
229
|
+
/* @__PURE__ */ jsx("span", { className: "fi-dot-pulse-red" }),
|
|
230
|
+
!isMobile && /* @__PURE__ */ jsx("div", { className: "fi-tooltip-right", children: "Habla con Free Intelligence" })
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// src/shell/ChatContent.tsx
|
|
237
|
+
import { Loader2 as Loader213 } from "lucide-react";
|
|
238
|
+
|
|
239
|
+
// src/composer/AutoResizeTextarea.tsx
|
|
240
|
+
import {
|
|
241
|
+
forwardRef,
|
|
242
|
+
useEffect,
|
|
243
|
+
useImperativeHandle,
|
|
244
|
+
useRef,
|
|
245
|
+
useState as useState2
|
|
246
|
+
} from "react";
|
|
247
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
248
|
+
var AutoResizeTextarea = forwardRef(function AutoResizeTextarea2({
|
|
249
|
+
value,
|
|
250
|
+
onChange,
|
|
251
|
+
maxRows = 5,
|
|
252
|
+
showCounter = false,
|
|
253
|
+
maxLength,
|
|
254
|
+
wrapperClassName = "",
|
|
255
|
+
wrapperStyle,
|
|
256
|
+
className = "",
|
|
257
|
+
...props
|
|
258
|
+
}, ref) {
|
|
259
|
+
const textareaRef = useRef(null);
|
|
260
|
+
useImperativeHandle(ref, () => textareaRef.current);
|
|
261
|
+
const [rows, setRows] = useState2(1);
|
|
262
|
+
useEffect(() => {
|
|
263
|
+
if (!textareaRef.current) return;
|
|
264
|
+
const textarea = textareaRef.current;
|
|
265
|
+
textarea.rows = 1;
|
|
266
|
+
textarea.style.height = "auto";
|
|
267
|
+
const computed = window.getComputedStyle(textarea);
|
|
268
|
+
const parsed = parseFloat(computed.lineHeight);
|
|
269
|
+
const lineHeight = Number.isFinite(parsed) && parsed > 0 ? parsed : 20;
|
|
270
|
+
const newRows = Math.max(
|
|
271
|
+
1,
|
|
272
|
+
Math.min(Math.ceil(textarea.scrollHeight / lineHeight), maxRows)
|
|
273
|
+
);
|
|
274
|
+
setRows(newRows);
|
|
275
|
+
textarea.rows = newRows;
|
|
276
|
+
textarea.style.height = `${newRows * lineHeight}px`;
|
|
277
|
+
textarea.style.width = "100%";
|
|
278
|
+
}, [value, maxRows]);
|
|
279
|
+
const charCount = typeof value === "string" ? value.length : 0;
|
|
280
|
+
const isNearLimit = maxLength && charCount > maxLength * 0.9;
|
|
281
|
+
const isOverLimit = maxLength && charCount > maxLength;
|
|
282
|
+
return /* @__PURE__ */ jsxs2("div", { className: `relative ${wrapperClassName}`, style: wrapperStyle, children: [
|
|
283
|
+
/* @__PURE__ */ jsx2(
|
|
284
|
+
"textarea",
|
|
285
|
+
{
|
|
286
|
+
ref: textareaRef,
|
|
287
|
+
value,
|
|
288
|
+
onChange,
|
|
289
|
+
maxLength,
|
|
290
|
+
className: `
|
|
291
|
+
resize-none
|
|
292
|
+
${className}
|
|
293
|
+
`,
|
|
294
|
+
rows,
|
|
295
|
+
...props
|
|
296
|
+
}
|
|
297
|
+
),
|
|
298
|
+
showCounter && maxLength && /* @__PURE__ */ jsxs2("div", { className: isOverLimit ? "chat-char-counter-error" : isNearLimit ? "chat-char-counter-warning" : "chat-char-counter-ok", children: [
|
|
299
|
+
charCount,
|
|
300
|
+
"/",
|
|
301
|
+
maxLength
|
|
302
|
+
] })
|
|
303
|
+
] });
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
// src/composer/Composer.tsx
|
|
307
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
308
|
+
function Composer({
|
|
309
|
+
message,
|
|
310
|
+
loading = false,
|
|
311
|
+
placeholder = "Escribe tu mensaje...",
|
|
312
|
+
onMessageChange,
|
|
313
|
+
onSend,
|
|
314
|
+
maxRows = 5,
|
|
315
|
+
areaClassName,
|
|
316
|
+
wrapperClassName,
|
|
317
|
+
wrapperStyle,
|
|
318
|
+
textareaClassName,
|
|
319
|
+
textareaRef
|
|
320
|
+
}) {
|
|
321
|
+
const handleKeyDown = (e) => {
|
|
322
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
323
|
+
e.preventDefault();
|
|
324
|
+
onSend();
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
return /* @__PURE__ */ jsx3("div", { className: areaClassName, children: /* @__PURE__ */ jsx3(
|
|
328
|
+
AutoResizeTextarea,
|
|
329
|
+
{
|
|
330
|
+
ref: textareaRef,
|
|
331
|
+
value: message,
|
|
332
|
+
onChange: (e) => onMessageChange(e.target.value),
|
|
333
|
+
onKeyDown: handleKeyDown,
|
|
334
|
+
placeholder,
|
|
335
|
+
disabled: loading,
|
|
336
|
+
maxRows,
|
|
337
|
+
showCounter: false,
|
|
338
|
+
wrapperClassName,
|
|
339
|
+
wrapperStyle,
|
|
340
|
+
className: textareaClassName
|
|
341
|
+
}
|
|
342
|
+
) });
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// src/shell/ChatWidgetContainer.tsx
|
|
346
|
+
import { MessageCircle as MessageCircle2 } from "lucide-react";
|
|
347
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
348
|
+
function ChatWidgetContainer(props) {
|
|
349
|
+
const { mode, title, children, embedded = false, onModeChange } = props;
|
|
350
|
+
const { isMobile, isTablet } = useBreakpoints(CHAT_BREAKPOINTS, {
|
|
351
|
+
ssrMatch: false
|
|
352
|
+
});
|
|
353
|
+
const effectiveMode = mode === "minimized" ? "minimized" : isMobile ? mode === "dense" ? "dense" : "fullscreen" : isTablet && (mode === "normal" || mode === "expanded") ? "expanded" : mode;
|
|
354
|
+
if (effectiveMode === "minimized") {
|
|
355
|
+
return /* @__PURE__ */ jsxs3("div", { className: "chat-container-minimized", onClick: () => onModeChange("normal"), children: [
|
|
356
|
+
/* @__PURE__ */ jsx4(MessageCircle2, { className: "chat-container-minimized-icon" }),
|
|
357
|
+
/* @__PURE__ */ jsx4("span", { className: "chat-container-minimized-title", children: title }),
|
|
358
|
+
/* @__PURE__ */ jsx4(
|
|
359
|
+
"button",
|
|
360
|
+
{
|
|
361
|
+
onClick: (e) => {
|
|
362
|
+
e.stopPropagation();
|
|
363
|
+
onModeChange("normal");
|
|
364
|
+
},
|
|
365
|
+
className: "ml-2 fi-hover-ghost",
|
|
366
|
+
"aria-label": "Expand chat",
|
|
367
|
+
children: /* @__PURE__ */ jsx4("div", { className: "chat-container-minimized-pulse" })
|
|
368
|
+
}
|
|
369
|
+
)
|
|
370
|
+
] });
|
|
371
|
+
}
|
|
372
|
+
if (effectiveMode === "expanded" && isTablet) {
|
|
373
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
374
|
+
/* @__PURE__ */ jsx4("div", { className: "chat-backdrop", onClick: () => onModeChange("normal") }),
|
|
375
|
+
/* @__PURE__ */ jsx4(
|
|
376
|
+
"div",
|
|
377
|
+
{
|
|
378
|
+
className: "chat-container-expanded-tablet",
|
|
379
|
+
style: { width: "min(90vw, 900px)", height: "min(90vh, 800px)" },
|
|
380
|
+
children
|
|
381
|
+
}
|
|
382
|
+
)
|
|
383
|
+
] });
|
|
384
|
+
}
|
|
385
|
+
if (effectiveMode === "expanded") {
|
|
386
|
+
return /* @__PURE__ */ jsx4(
|
|
387
|
+
"div",
|
|
388
|
+
{
|
|
389
|
+
className: "chat-container-expanded",
|
|
390
|
+
style: {
|
|
391
|
+
width: "min(80vw, 1200px)",
|
|
392
|
+
height: "700px",
|
|
393
|
+
maxWidth: "calc(100vw - 3rem)",
|
|
394
|
+
maxHeight: "calc(100vh - 3rem)"
|
|
395
|
+
},
|
|
396
|
+
children
|
|
397
|
+
}
|
|
398
|
+
);
|
|
399
|
+
}
|
|
400
|
+
if (embedded && (effectiveMode === "fullscreen" || effectiveMode === "dense")) {
|
|
401
|
+
return /* @__PURE__ */ jsx4("div", { className: "chat-container-embedded", children });
|
|
402
|
+
}
|
|
403
|
+
if (effectiveMode === "dense") {
|
|
404
|
+
return /* @__PURE__ */ jsx4("div", { className: "chat-container-dense", children });
|
|
405
|
+
}
|
|
406
|
+
if (effectiveMode === "fullscreen") {
|
|
407
|
+
return /* @__PURE__ */ jsx4("div", { className: "chat-container-fullscreen", children });
|
|
408
|
+
}
|
|
409
|
+
return /* @__PURE__ */ jsx4("div", { className: "chat-container-normal", children });
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// src/shell/ChatWidgetHeader.tsx
|
|
413
|
+
import { X, Minimize2, Maximize2, MessageCircle as MessageCircle3, Search } from "lucide-react";
|
|
414
|
+
import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
415
|
+
var HEADER_BTN_CLASS = "fi-btn-ghost fi-btn-sm chat-header-btn";
|
|
416
|
+
var DEFAULT_HEADER_GRADIENT = "bg-gradient-to-r from-emerald-600 to-cyan-600";
|
|
417
|
+
function ChatWidgetHeader({
|
|
418
|
+
title,
|
|
419
|
+
subtitle,
|
|
420
|
+
backgroundClass = DEFAULT_HEADER_GRADIENT,
|
|
421
|
+
mode,
|
|
422
|
+
showControls = true,
|
|
423
|
+
showHistorySearch = true,
|
|
424
|
+
onNavigate,
|
|
425
|
+
onMinimize,
|
|
426
|
+
onMaximize,
|
|
427
|
+
onToggleDenseMode,
|
|
428
|
+
onClose,
|
|
429
|
+
onHistorySearch
|
|
430
|
+
}) {
|
|
431
|
+
return /* @__PURE__ */ jsxs4("div", { className: `${backgroundClass} chat-header`, children: [
|
|
432
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
433
|
+
/* @__PURE__ */ jsx5(
|
|
434
|
+
"button",
|
|
435
|
+
{
|
|
436
|
+
type: "button",
|
|
437
|
+
onClick: () => onNavigate?.("chat"),
|
|
438
|
+
className: "chat-header-icon",
|
|
439
|
+
title: "Abrir chat completo",
|
|
440
|
+
"aria-label": "Abrir chat completo",
|
|
441
|
+
children: /* @__PURE__ */ jsx5(MessageCircle3, { className: "h-5 w-5 text-white" })
|
|
442
|
+
}
|
|
443
|
+
),
|
|
444
|
+
/* @__PURE__ */ jsxs4("div", { className: "min-w-0", children: [
|
|
445
|
+
/* @__PURE__ */ jsx5("h3", { className: "chat-header-title", children: title }),
|
|
446
|
+
subtitle && /* @__PURE__ */ jsx5("p", { className: "chat-header-subtitle", children: subtitle })
|
|
447
|
+
] })
|
|
448
|
+
] }),
|
|
449
|
+
/* @__PURE__ */ jsx5("div", { className: "chat-header-controls", children: showControls && /* @__PURE__ */ jsxs4(Fragment2, { children: [
|
|
450
|
+
showHistorySearch && onHistorySearch && mode !== "minimized" && /* @__PURE__ */ jsx5("button", { onClick: onHistorySearch, className: HEADER_BTN_CLASS, "aria-label": "Search history", title: "Buscar en historial", type: "button", children: /* @__PURE__ */ jsx5(Search, { className: "h-4 w-4" }) }),
|
|
451
|
+
mode === "fullscreen" && onToggleDenseMode && /* @__PURE__ */ jsx5("button", { onClick: onToggleDenseMode, className: HEADER_BTN_CLASS, "aria-label": "Cambiar a modo denso", title: "Modo denso (sin controles)", type: "button", children: /* @__PURE__ */ jsxs4("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [
|
|
452
|
+
/* @__PURE__ */ jsx5("path", { d: "M0 3.5A1.5 1.5 0 0 1 1.5 2h13A1.5 1.5 0 0 1 16 3.5v9a1.5 1.5 0 0 1-1.5 1.5h-13A1.5 1.5 0 0 1 0 12.5v-9zM1.5 3a.5.5 0 0 0-.5.5v9a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9a.5.5 0 0 0-.5-.5h-13z" }),
|
|
453
|
+
/* @__PURE__ */ jsx5("path", { d: "M3 4.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5z" })
|
|
454
|
+
] }) }),
|
|
455
|
+
mode === "dense" && onToggleDenseMode && /* @__PURE__ */ jsx5("button", { onClick: onToggleDenseMode, className: HEADER_BTN_CLASS, "aria-label": "Cambiar a modo expandido", title: "Modo expandido (con controles)", type: "button", children: /* @__PURE__ */ jsxs4("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "currentColor", viewBox: "0 0 16 16", children: [
|
|
456
|
+
/* @__PURE__ */ jsx5("path", { d: "M14 1a1 1 0 0 1 1 1v12a1 1 0 0 1-1 1H2a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1h12zM2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2z" }),
|
|
457
|
+
/* @__PURE__ */ jsx5("path", { d: "M6.5 4.5a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1 0-1h2V5a.5.5 0 0 1 .5-.5zM8 8.5a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1 0-1h2v-2a.5.5 0 0 1 .5-.5zm3-4a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1 0-1h2V5a.5.5 0 0 1 .5-.5zm0 6a.5.5 0 0 1 .5.5v3a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1 0-1h2v-2a.5.5 0 0 1 .5-.5z" })
|
|
458
|
+
] }) }),
|
|
459
|
+
mode === "expanded" && /* @__PURE__ */ jsx5("button", { onClick: onMinimize, className: HEADER_BTN_CLASS, "aria-label": "Restaurar tama\xF1o", title: "Restaurar a tama\xF1o normal", type: "button", children: /* @__PURE__ */ jsx5(Minimize2, { className: "h-4 w-4" }) }),
|
|
460
|
+
mode === "normal" && /* @__PURE__ */ jsx5("button", { onClick: onMaximize, className: HEADER_BTN_CLASS, "aria-label": "Expandir", title: "Expandir (60% m\xE1s grande)", type: "button", children: /* @__PURE__ */ jsx5(Maximize2, { className: "h-4 w-4" }) }),
|
|
461
|
+
/* @__PURE__ */ jsx5("button", { onClick: onClose, className: HEADER_BTN_CLASS, "aria-label": "Close", title: "Cerrar", type: "button", children: /* @__PURE__ */ jsx5(X, { className: "h-5 w-5" }) })
|
|
462
|
+
] }) })
|
|
463
|
+
] });
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// src/shell/ChatToolbar.tsx
|
|
467
|
+
import { useState as useState12, useRef as useRef7, useEffect as useEffect10 } from "react";
|
|
468
|
+
import { createPortal } from "react-dom";
|
|
469
|
+
import { Paperclip, Globe, Type, Zap, Trash, Sparkles, BookOpen, Terminal, MoreVertical, Send, Loader2 as Loader211 } from "lucide-react";
|
|
470
|
+
|
|
471
|
+
// src/voice/recording/RecordingButton.tsx
|
|
472
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
473
|
+
import { Loader2 } from "lucide-react";
|
|
474
|
+
|
|
475
|
+
// src/voice/recording/types.ts
|
|
476
|
+
var BUTTON_SIZES = {
|
|
477
|
+
sm: {
|
|
478
|
+
button: "rec-btn-sm",
|
|
479
|
+
icon: "rec-icon-sm",
|
|
480
|
+
ring: "rec-ring-sm"
|
|
481
|
+
},
|
|
482
|
+
md: {
|
|
483
|
+
button: "rec-btn-md",
|
|
484
|
+
icon: "rec-icon-md",
|
|
485
|
+
ring: "rec-ring-md"
|
|
486
|
+
},
|
|
487
|
+
lg: {
|
|
488
|
+
button: "rec-btn-lg",
|
|
489
|
+
icon: "rec-icon-lg",
|
|
490
|
+
ring: "rec-ring-lg"
|
|
491
|
+
},
|
|
492
|
+
xl: {
|
|
493
|
+
button: "rec-btn-xl",
|
|
494
|
+
icon: "rec-icon-xl",
|
|
495
|
+
ring: "rec-ring-xl"
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
|
|
499
|
+
// src/voice/recording/RecordingButton.tsx
|
|
500
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
501
|
+
var RecordingButton = forwardRef2(
|
|
502
|
+
function RecordingButton2({
|
|
503
|
+
size = "md",
|
|
504
|
+
bgColor,
|
|
505
|
+
icon: Icon,
|
|
506
|
+
iconSpin = false,
|
|
507
|
+
iconColor = "rec-icon-white",
|
|
508
|
+
disabled = false,
|
|
509
|
+
onClick,
|
|
510
|
+
ariaLabel,
|
|
511
|
+
className = "",
|
|
512
|
+
borderStyle = "",
|
|
513
|
+
animate = ""
|
|
514
|
+
}, ref) {
|
|
515
|
+
const sizeConfig = BUTTON_SIZES[size];
|
|
516
|
+
const DisplayIcon = iconSpin ? Loader2 : Icon;
|
|
517
|
+
return /* @__PURE__ */ jsx6(
|
|
518
|
+
"button",
|
|
519
|
+
{
|
|
520
|
+
ref,
|
|
521
|
+
onClick,
|
|
522
|
+
disabled,
|
|
523
|
+
"aria-label": ariaLabel,
|
|
524
|
+
className: `fi-recording-btn-base ${sizeConfig.button} ${bgColor} ${borderStyle} ${animate} ${disabled ? "rec-btn-disabled" : "rec-btn-enabled"} ${className}`,
|
|
525
|
+
children: /* @__PURE__ */ jsx6(
|
|
526
|
+
DisplayIcon,
|
|
527
|
+
{
|
|
528
|
+
className: `${sizeConfig.icon} ${iconColor} ${iconSpin ? "rec-icon-spin" : ""}`
|
|
529
|
+
}
|
|
530
|
+
)
|
|
531
|
+
}
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
// src/voice/recording/PulseRings.tsx
|
|
537
|
+
import { motion } from "framer-motion";
|
|
538
|
+
import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
539
|
+
function PingRings({ color = "yellow-500" }) {
|
|
540
|
+
const bgClass = `rec-pulse-bg-${color}`;
|
|
541
|
+
return /* @__PURE__ */ jsxs5(Fragment3, { children: [
|
|
542
|
+
/* @__PURE__ */ jsx7(
|
|
543
|
+
"div",
|
|
544
|
+
{
|
|
545
|
+
className: `rec-pulse-ping-primary ${bgClass}`
|
|
546
|
+
}
|
|
547
|
+
),
|
|
548
|
+
/* @__PURE__ */ jsx7(
|
|
549
|
+
"div",
|
|
550
|
+
{
|
|
551
|
+
className: `rec-pulse-ping-secondary ${bgClass}`,
|
|
552
|
+
style: { animation: "pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite" }
|
|
553
|
+
}
|
|
554
|
+
)
|
|
555
|
+
] });
|
|
556
|
+
}
|
|
557
|
+
function ConcentricRings({ color = "yellow-500" }) {
|
|
558
|
+
const borderClass = `rec-pulse-border-${color}`;
|
|
559
|
+
const rings = [
|
|
560
|
+
{ scale: 1.3, opacity: 0.4, delay: 0 },
|
|
561
|
+
{ scale: 1.5, opacity: 0.3, delay: 0.2 },
|
|
562
|
+
{ scale: 1.7, opacity: 0.2, delay: 0.4 }
|
|
563
|
+
];
|
|
564
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: rings.map((ring, i) => /* @__PURE__ */ jsx7(
|
|
565
|
+
motion.div,
|
|
566
|
+
{
|
|
567
|
+
className: `rec-pulse-concentric ${borderClass}`,
|
|
568
|
+
initial: { scale: 1, opacity: ring.opacity },
|
|
569
|
+
animate: {
|
|
570
|
+
scale: [1, ring.scale, 1],
|
|
571
|
+
opacity: [ring.opacity, ring.opacity * 0.5, ring.opacity]
|
|
572
|
+
},
|
|
573
|
+
transition: {
|
|
574
|
+
duration: 1.5,
|
|
575
|
+
repeat: Infinity,
|
|
576
|
+
ease: "easeInOut",
|
|
577
|
+
delay: ring.delay
|
|
578
|
+
}
|
|
579
|
+
},
|
|
580
|
+
i
|
|
581
|
+
)) });
|
|
582
|
+
}
|
|
583
|
+
function VADRings({
|
|
584
|
+
audioLevel = 0,
|
|
585
|
+
isSilent = true
|
|
586
|
+
}) {
|
|
587
|
+
const audioScale = !isSilent ? Math.max(1, 1 + audioLevel / 255 * 1) : 1;
|
|
588
|
+
const ringColor = isSilent ? "rgb(239, 68, 68)" : "rgb(34, 197, 94)";
|
|
589
|
+
const rings = [
|
|
590
|
+
{ baseScale: 1.2, opacityBase: 0.6 },
|
|
591
|
+
{ baseScale: 1.4, opacityBase: 0.4 },
|
|
592
|
+
{ baseScale: 1.6, opacityBase: 0.2 }
|
|
593
|
+
];
|
|
594
|
+
return /* @__PURE__ */ jsx7(Fragment3, { children: rings.map((ring, i) => /* @__PURE__ */ jsx7(
|
|
595
|
+
motion.div,
|
|
596
|
+
{
|
|
597
|
+
className: "rec-pulse-vad",
|
|
598
|
+
style: { borderColor: ringColor },
|
|
599
|
+
animate: {
|
|
600
|
+
scale: audioScale * ring.baseScale,
|
|
601
|
+
opacity: ring.opacityBase
|
|
602
|
+
},
|
|
603
|
+
transition: {
|
|
604
|
+
duration: 0.2,
|
|
605
|
+
// Transición suave pero rápida para seguir el ritmo
|
|
606
|
+
ease: "easeOut"
|
|
607
|
+
}
|
|
608
|
+
},
|
|
609
|
+
i
|
|
610
|
+
)) });
|
|
611
|
+
}
|
|
612
|
+
function PulseRings({
|
|
613
|
+
style,
|
|
614
|
+
color = "yellow-500",
|
|
615
|
+
audioLevel = 0,
|
|
616
|
+
isSilent = true,
|
|
617
|
+
className = ""
|
|
618
|
+
}) {
|
|
619
|
+
if (style === "none") return null;
|
|
620
|
+
return /* @__PURE__ */ jsxs5("div", { className: `rec-pulse-container ${className}`, children: [
|
|
621
|
+
style === "ping" && /* @__PURE__ */ jsx7(PingRings, { color }),
|
|
622
|
+
style === "rings" && /* @__PURE__ */ jsx7(ConcentricRings, { color }),
|
|
623
|
+
style === "vad" && /* @__PURE__ */ jsx7(VADRings, { audioLevel, isSilent })
|
|
624
|
+
] });
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/voice/recording/RecordingTimer.tsx
|
|
628
|
+
import { motion as motion2 } from "framer-motion";
|
|
629
|
+
import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
630
|
+
function formatRecordingTime(seconds) {
|
|
631
|
+
const mins = Math.floor(seconds / 60);
|
|
632
|
+
const secs = seconds % 60;
|
|
633
|
+
return `${mins}:${secs.toString().padStart(2, "0")}`;
|
|
634
|
+
}
|
|
635
|
+
var SIZE_CLASSES = {
|
|
636
|
+
sm: "rec-timer-sm",
|
|
637
|
+
md: "rec-timer-md",
|
|
638
|
+
lg: "rec-timer-lg"
|
|
639
|
+
};
|
|
640
|
+
function RecordingTimer({
|
|
641
|
+
time,
|
|
642
|
+
visible = true,
|
|
643
|
+
size = "md",
|
|
644
|
+
showDot = false,
|
|
645
|
+
textColor = "rec-timer-text-white",
|
|
646
|
+
dotColor = "rec-timer-dot-red",
|
|
647
|
+
className = ""
|
|
648
|
+
}) {
|
|
649
|
+
if (!visible || time <= 0) return null;
|
|
650
|
+
return /* @__PURE__ */ jsxs6("div", { className: `rec-timer-wrap ${SIZE_CLASSES[size]} ${className}`, children: [
|
|
651
|
+
showDot && /* @__PURE__ */ jsx8(
|
|
652
|
+
motion2.div,
|
|
653
|
+
{
|
|
654
|
+
className: `rec-timer-dot ${dotColor}`,
|
|
655
|
+
animate: { opacity: [1, 0.3, 1] },
|
|
656
|
+
transition: {
|
|
657
|
+
duration: 1.5,
|
|
658
|
+
repeat: Infinity,
|
|
659
|
+
ease: "easeInOut"
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
),
|
|
663
|
+
/* @__PURE__ */ jsx8("span", { className: `${textColor} rec-timer-value`, children: formatRecordingTime(time) })
|
|
664
|
+
] });
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
// src/voice/recording/StatusText.tsx
|
|
668
|
+
import { Loader2 as Loader22 } from "lucide-react";
|
|
669
|
+
import { motion as motion3 } from "framer-motion";
|
|
670
|
+
import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
671
|
+
|
|
672
|
+
// src/voice/VoiceMicButton.tsx
|
|
673
|
+
import { Mic, Square, Loader2 as Loader23 } from "lucide-react";
|
|
674
|
+
import { motion as motion4 } from "framer-motion";
|
|
675
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
676
|
+
function deriveState(isRecording, isTranscribing) {
|
|
677
|
+
if (isTranscribing && !isRecording) return "processing";
|
|
678
|
+
if (isRecording) return "recording";
|
|
679
|
+
return "idle";
|
|
680
|
+
}
|
|
681
|
+
function getButtonColor(state, isSilent) {
|
|
682
|
+
if (state === "recording") {
|
|
683
|
+
return isSilent ? "bg-red-500 hover:bg-red-600 text-white" : "bg-green-500 hover:bg-green-600 text-white";
|
|
684
|
+
}
|
|
685
|
+
if (state === "processing") {
|
|
686
|
+
return "bg-blue-500 text-white";
|
|
687
|
+
}
|
|
688
|
+
return "bg-gray-200 hover:bg-gray-300 text-gray-700 dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-gray-200";
|
|
689
|
+
}
|
|
690
|
+
function VoiceMicButton({
|
|
691
|
+
isRecording,
|
|
692
|
+
isTranscribing,
|
|
693
|
+
audioLevel,
|
|
694
|
+
isSilent,
|
|
695
|
+
recordingTime,
|
|
696
|
+
onStart,
|
|
697
|
+
onStop,
|
|
698
|
+
className = ""
|
|
699
|
+
}) {
|
|
700
|
+
const state = deriveState(isRecording, isTranscribing);
|
|
701
|
+
const isDisabled = isTranscribing && !isRecording;
|
|
702
|
+
const handleClick = () => {
|
|
703
|
+
if (isRecording) {
|
|
704
|
+
onStop();
|
|
705
|
+
} else if (!isTranscribing) {
|
|
706
|
+
onStart();
|
|
707
|
+
}
|
|
708
|
+
};
|
|
709
|
+
const icon = isTranscribing ? Loader23 : isRecording ? Square : Mic;
|
|
710
|
+
const iconColor = state === "idle" ? "text-gray-700 dark:text-gray-200" : "text-white";
|
|
711
|
+
return /* @__PURE__ */ jsxs8("div", { className: `relative inline-flex items-center gap-3 ${className}`, children: [
|
|
712
|
+
/* @__PURE__ */ jsxs8("div", { className: "relative", children: [
|
|
713
|
+
isRecording && /* @__PURE__ */ jsx10(
|
|
714
|
+
PulseRings,
|
|
715
|
+
{
|
|
716
|
+
style: "vad",
|
|
717
|
+
audioLevel,
|
|
718
|
+
isSilent
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
/* @__PURE__ */ jsx10(
|
|
722
|
+
motion4.div,
|
|
723
|
+
{
|
|
724
|
+
animate: {
|
|
725
|
+
scale: isRecording && !isSilent ? [1, 1.05, 1] : 1
|
|
726
|
+
},
|
|
727
|
+
transition: {
|
|
728
|
+
duration: 0.6,
|
|
729
|
+
repeat: isRecording && !isSilent ? Infinity : 0,
|
|
730
|
+
ease: "easeInOut"
|
|
731
|
+
},
|
|
732
|
+
children: /* @__PURE__ */ jsx10(
|
|
733
|
+
RecordingButton,
|
|
734
|
+
{
|
|
735
|
+
size: "md",
|
|
736
|
+
bgColor: getButtonColor(state, isSilent),
|
|
737
|
+
icon,
|
|
738
|
+
iconSpin: isTranscribing && !isRecording,
|
|
739
|
+
iconColor,
|
|
740
|
+
disabled: isDisabled,
|
|
741
|
+
onClick: handleClick,
|
|
742
|
+
ariaLabel: isRecording ? "Detener grabaci\xF3n" : "Iniciar grabaci\xF3n de voz",
|
|
743
|
+
className: "relative z-10"
|
|
744
|
+
}
|
|
745
|
+
)
|
|
746
|
+
}
|
|
747
|
+
)
|
|
748
|
+
] }),
|
|
749
|
+
isRecording && /* @__PURE__ */ jsx10(
|
|
750
|
+
motion4.div,
|
|
751
|
+
{
|
|
752
|
+
initial: { opacity: 0, x: -10 },
|
|
753
|
+
animate: { opacity: 1, x: 0 },
|
|
754
|
+
exit: { opacity: 0, x: -10 },
|
|
755
|
+
children: /* @__PURE__ */ jsx10(
|
|
756
|
+
RecordingTimer,
|
|
757
|
+
{
|
|
758
|
+
time: recordingTime,
|
|
759
|
+
size: "sm",
|
|
760
|
+
showDot: true,
|
|
761
|
+
textColor: "text-gray-700 dark:text-gray-300"
|
|
762
|
+
}
|
|
763
|
+
)
|
|
764
|
+
}
|
|
765
|
+
),
|
|
766
|
+
isTranscribing && !isRecording && /* @__PURE__ */ jsx10(
|
|
767
|
+
motion4.div,
|
|
768
|
+
{
|
|
769
|
+
initial: { opacity: 0 },
|
|
770
|
+
animate: { opacity: 1 },
|
|
771
|
+
className: "text-sm text-blue-600 dark:fi-text-primary font-medium",
|
|
772
|
+
children: "Transcribiendo..."
|
|
773
|
+
}
|
|
774
|
+
)
|
|
775
|
+
] });
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
// src/voice/SpeakButton.tsx
|
|
779
|
+
import { Volume2, Loader2 as Loader24, Play } from "lucide-react";
|
|
780
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
781
|
+
|
|
782
|
+
// src/voice/useAudioPlayer.ts
|
|
783
|
+
import { useEffect as useEffect2, useMemo, useRef as useRef2, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
784
|
+
|
|
785
|
+
// src/voice/AudioPlayer.tsx
|
|
786
|
+
import { Play as Play2, Pause, Square as Square2, Loader2 as Loader25, AlertCircle } from "lucide-react";
|
|
787
|
+
import { useEffect as useEffect3 } from "react";
|
|
788
|
+
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
789
|
+
|
|
790
|
+
// src/voice/RichAudioPlayer.tsx
|
|
791
|
+
import {
|
|
792
|
+
Play as Play3,
|
|
793
|
+
Pause as Pause2,
|
|
794
|
+
Square as Square3,
|
|
795
|
+
Loader2 as Loader26,
|
|
796
|
+
AlertCircle as AlertCircle2,
|
|
797
|
+
RotateCcw,
|
|
798
|
+
RotateCw
|
|
799
|
+
} from "lucide-react";
|
|
800
|
+
import { useEffect as useEffect4 } from "react";
|
|
801
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
802
|
+
|
|
803
|
+
// src/voice/AudioVisualizer.tsx
|
|
804
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
805
|
+
|
|
806
|
+
// src/voice/ComposerMicSlot.tsx
|
|
807
|
+
import { Mic as Mic2, MicOff, Square as Square4, Loader2 as Loader27 } from "lucide-react";
|
|
808
|
+
import { jsx as jsx15 } from "react/jsx-runtime";
|
|
809
|
+
|
|
810
|
+
// src/voice/useVoice.ts
|
|
811
|
+
import { useCallback as useCallback2, useRef as useRef3, useState as useState3 } from "react";
|
|
812
|
+
|
|
813
|
+
// src/voice/useDictation.ts
|
|
814
|
+
import { useCallback as useCallback4, useState as useState6 } from "react";
|
|
815
|
+
|
|
816
|
+
// src/voice/useRecorder.ts
|
|
817
|
+
import { useState as useState4, useRef as useRef4, useCallback as useCallback3 } from "react";
|
|
818
|
+
|
|
819
|
+
// src/voice/useAudioAnalysis.ts
|
|
820
|
+
import { useState as useState5, useRef as useRef5, useEffect as useEffect5 } from "react";
|
|
821
|
+
|
|
822
|
+
// src/voice/audioArtifact.ts
|
|
823
|
+
var AUDIO_QUEUE_DEFAULTS = {
|
|
824
|
+
maxItems: 10,
|
|
825
|
+
maxBytes: 50 * 1024 * 1024,
|
|
826
|
+
// 50 MB total queue
|
|
827
|
+
maxBytesPerItem: 10 * 1024 * 1024
|
|
828
|
+
// 10 MB per artifact
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// src/voice/useDurableRecording.ts
|
|
832
|
+
import { useState as useState7, useRef as useRef6, useCallback as useCallback5, useEffect as useEffect6 } from "react";
|
|
833
|
+
|
|
834
|
+
// src/voice/useAudioQueue.ts
|
|
835
|
+
import { useState as useState8, useEffect as useEffect7, useCallback as useCallback6 } from "react";
|
|
836
|
+
|
|
837
|
+
// src/voice/AudioQueuePanel.tsx
|
|
838
|
+
import { useEffect as useEffect8, useState as useState10 } from "react";
|
|
839
|
+
import { Loader2 as Loader29, Trash2 as Trash22, Info } from "lucide-react";
|
|
840
|
+
|
|
841
|
+
// src/voice/AudioQueueItem.tsx
|
|
842
|
+
import { useState as useState9, useCallback as useCallback7 } from "react";
|
|
843
|
+
import {
|
|
844
|
+
Mic as Mic3,
|
|
845
|
+
PauseCircle,
|
|
846
|
+
CheckCircle2,
|
|
847
|
+
CheckCheck,
|
|
848
|
+
AlertCircle as AlertCircle3,
|
|
849
|
+
Loader2 as Loader28,
|
|
850
|
+
Play as Play4,
|
|
851
|
+
RotateCcw as RotateCcw2,
|
|
852
|
+
Trash2,
|
|
853
|
+
FileAudio
|
|
854
|
+
} from "lucide-react";
|
|
855
|
+
import { jsx as jsx16, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
856
|
+
|
|
857
|
+
// src/voice/AudioQueuePanel.tsx
|
|
858
|
+
import { jsx as jsx17, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
859
|
+
|
|
860
|
+
// src/voice/AudioDraftPlayer.tsx
|
|
861
|
+
import { useState as useState11, useEffect as useEffect9 } from "react";
|
|
862
|
+
import { Play as Play5, Trash2 as Trash23, Loader2 as Loader210, RotateCcw as RotateCcw3, ArrowUp } from "lucide-react";
|
|
863
|
+
import { jsx as jsx18, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
864
|
+
|
|
865
|
+
// src/shell/ChatToolbar.tsx
|
|
866
|
+
import { Fragment as Fragment4, jsx as jsx19, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
867
|
+
function ChatToolbar({
|
|
868
|
+
showAttach = true,
|
|
869
|
+
showLanguage = true,
|
|
870
|
+
showFormatting = true,
|
|
871
|
+
showResponseMode = true,
|
|
872
|
+
showVoice = true,
|
|
873
|
+
showPersonaSelector = true,
|
|
874
|
+
showThinkingToggle = true,
|
|
875
|
+
responseMode = "explanatory",
|
|
876
|
+
selectedPersona: _selectedPersona = "general_assistant",
|
|
877
|
+
showThinking = true,
|
|
878
|
+
voiceRecording,
|
|
879
|
+
personaSelector,
|
|
880
|
+
onAttach,
|
|
881
|
+
onLanguage,
|
|
882
|
+
onFormatting,
|
|
883
|
+
onResponseModeToggle,
|
|
884
|
+
onVoiceStart,
|
|
885
|
+
onVoiceStop,
|
|
886
|
+
onShowThinkingToggle,
|
|
887
|
+
showClear = true,
|
|
888
|
+
onClearConversation,
|
|
889
|
+
showCopyCurl = true,
|
|
890
|
+
onCopyCurl,
|
|
891
|
+
onSend,
|
|
892
|
+
canSend = false,
|
|
893
|
+
sendLoading = false
|
|
894
|
+
}) {
|
|
895
|
+
const [overflowOpen, setOverflowOpen] = useState12(false);
|
|
896
|
+
const overflowButtonRef = useRef7(null);
|
|
897
|
+
const [dropdownPosition, setDropdownPosition] = useState12({ top: 0, left: 0 });
|
|
898
|
+
useEffect10(() => {
|
|
899
|
+
if (overflowOpen && overflowButtonRef.current) {
|
|
900
|
+
const rect = overflowButtonRef.current.getBoundingClientRect();
|
|
901
|
+
setDropdownPosition({
|
|
902
|
+
top: rect.top - 8,
|
|
903
|
+
// 8px margin above button
|
|
904
|
+
left: rect.left
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
}, [overflowOpen]);
|
|
908
|
+
const buttonBaseClass = "chat-toolbar-btn";
|
|
909
|
+
const iconClass = "chat-toolbar-icon";
|
|
910
|
+
return /* @__PURE__ */ jsxs14("div", { className: "chat-toolbar", children: [
|
|
911
|
+
/* @__PURE__ */ jsxs14("div", { className: "fi-flex-gap-sm", children: [
|
|
912
|
+
showPersonaSelector && personaSelector,
|
|
913
|
+
(showAttach || showLanguage || showFormatting) && /* @__PURE__ */ jsxs14("div", { className: "relative", children: [
|
|
914
|
+
/* @__PURE__ */ jsx19(
|
|
915
|
+
"button",
|
|
916
|
+
{
|
|
917
|
+
ref: overflowButtonRef,
|
|
918
|
+
onClick: () => setOverflowOpen(!overflowOpen),
|
|
919
|
+
className: buttonBaseClass,
|
|
920
|
+
title: "M\xE1s opciones",
|
|
921
|
+
"aria-label": "M\xE1s opciones",
|
|
922
|
+
children: /* @__PURE__ */ jsx19(MoreVertical, { className: iconClass })
|
|
923
|
+
}
|
|
924
|
+
),
|
|
925
|
+
overflowOpen && createPortal(
|
|
926
|
+
/* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
927
|
+
/* @__PURE__ */ jsx19(
|
|
928
|
+
"div",
|
|
929
|
+
{
|
|
930
|
+
className: "fixed inset-0 z-[9998]",
|
|
931
|
+
onClick: () => setOverflowOpen(false),
|
|
932
|
+
"aria-hidden": "true"
|
|
933
|
+
}
|
|
934
|
+
),
|
|
935
|
+
/* @__PURE__ */ jsxs14(
|
|
936
|
+
"div",
|
|
937
|
+
{
|
|
938
|
+
className: "chat-dropdown",
|
|
939
|
+
style: {
|
|
940
|
+
top: dropdownPosition.top,
|
|
941
|
+
left: dropdownPosition.left,
|
|
942
|
+
transform: "translateY(-100%)"
|
|
943
|
+
},
|
|
944
|
+
children: [
|
|
945
|
+
showAttach && /* @__PURE__ */ jsxs14(
|
|
946
|
+
"button",
|
|
947
|
+
{
|
|
948
|
+
onClick: () => {
|
|
949
|
+
onAttach?.();
|
|
950
|
+
setOverflowOpen(false);
|
|
951
|
+
},
|
|
952
|
+
className: "chat-dropdown-item",
|
|
953
|
+
children: [
|
|
954
|
+
/* @__PURE__ */ jsx19(Paperclip, { className: "fi-icon-sm" }),
|
|
955
|
+
/* @__PURE__ */ jsx19("span", { children: "Adjuntar archivo" })
|
|
956
|
+
]
|
|
957
|
+
}
|
|
958
|
+
),
|
|
959
|
+
showLanguage && /* @__PURE__ */ jsxs14(
|
|
960
|
+
"button",
|
|
961
|
+
{
|
|
962
|
+
onClick: () => {
|
|
963
|
+
onLanguage?.();
|
|
964
|
+
setOverflowOpen(false);
|
|
965
|
+
},
|
|
966
|
+
className: "chat-dropdown-item",
|
|
967
|
+
children: [
|
|
968
|
+
/* @__PURE__ */ jsx19(Globe, { className: "fi-icon-sm" }),
|
|
969
|
+
/* @__PURE__ */ jsx19("span", { children: "Cambiar idioma" })
|
|
970
|
+
]
|
|
971
|
+
}
|
|
972
|
+
),
|
|
973
|
+
showFormatting && /* @__PURE__ */ jsxs14(
|
|
974
|
+
"button",
|
|
975
|
+
{
|
|
976
|
+
onClick: () => {
|
|
977
|
+
onFormatting?.();
|
|
978
|
+
setOverflowOpen(false);
|
|
979
|
+
},
|
|
980
|
+
className: "chat-dropdown-item",
|
|
981
|
+
children: [
|
|
982
|
+
/* @__PURE__ */ jsx19(Type, { className: "fi-icon-sm" }),
|
|
983
|
+
/* @__PURE__ */ jsx19("span", { children: "Formato de texto" })
|
|
984
|
+
]
|
|
985
|
+
}
|
|
986
|
+
),
|
|
987
|
+
showCopyCurl && /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
988
|
+
/* @__PURE__ */ jsx19("div", { className: "chat-dropdown-divider" }),
|
|
989
|
+
/* @__PURE__ */ jsxs14(
|
|
990
|
+
"button",
|
|
991
|
+
{
|
|
992
|
+
onClick: () => {
|
|
993
|
+
onCopyCurl?.();
|
|
994
|
+
setOverflowOpen(false);
|
|
995
|
+
},
|
|
996
|
+
className: "chat-dropdown-item fi-text-warning hover:bg-amber-900/20 hover:text-amber-300",
|
|
997
|
+
children: [
|
|
998
|
+
/* @__PURE__ */ jsx19(Terminal, { className: "fi-icon-sm" }),
|
|
999
|
+
/* @__PURE__ */ jsx19("span", { children: "Copiar plantilla curl" })
|
|
1000
|
+
]
|
|
1001
|
+
}
|
|
1002
|
+
)
|
|
1003
|
+
] }),
|
|
1004
|
+
showThinkingToggle && /* @__PURE__ */ jsxs14("div", { className: "@md:hidden", children: [
|
|
1005
|
+
/* @__PURE__ */ jsx19("div", { className: "chat-dropdown-divider" }),
|
|
1006
|
+
/* @__PURE__ */ jsxs14(
|
|
1007
|
+
"button",
|
|
1008
|
+
{
|
|
1009
|
+
onClick: () => {
|
|
1010
|
+
onShowThinkingToggle?.();
|
|
1011
|
+
setOverflowOpen(false);
|
|
1012
|
+
},
|
|
1013
|
+
className: `chat-dropdown-item ${showThinking ? "fi-text-purple hover:bg-purple-900/20" : ""}`,
|
|
1014
|
+
children: [
|
|
1015
|
+
/* @__PURE__ */ jsx19(Sparkles, { className: "fi-icon-sm" }),
|
|
1016
|
+
/* @__PURE__ */ jsx19("span", { children: showThinking ? "Ocultar razonamiento" : "Mostrar razonamiento" })
|
|
1017
|
+
]
|
|
1018
|
+
}
|
|
1019
|
+
)
|
|
1020
|
+
] }),
|
|
1021
|
+
showClear && /* @__PURE__ */ jsxs14("div", { className: "@md:hidden", children: [
|
|
1022
|
+
/* @__PURE__ */ jsx19("div", { className: "chat-dropdown-divider" }),
|
|
1023
|
+
/* @__PURE__ */ jsxs14(
|
|
1024
|
+
"button",
|
|
1025
|
+
{
|
|
1026
|
+
onClick: () => {
|
|
1027
|
+
onClearConversation?.();
|
|
1028
|
+
setOverflowOpen(false);
|
|
1029
|
+
},
|
|
1030
|
+
className: "chat-dropdown-item-danger",
|
|
1031
|
+
children: [
|
|
1032
|
+
/* @__PURE__ */ jsx19(Trash, { className: "fi-icon-sm" }),
|
|
1033
|
+
/* @__PURE__ */ jsx19("span", { children: "Limpiar conversaci\xF3n" })
|
|
1034
|
+
]
|
|
1035
|
+
}
|
|
1036
|
+
)
|
|
1037
|
+
] })
|
|
1038
|
+
]
|
|
1039
|
+
}
|
|
1040
|
+
)
|
|
1041
|
+
] }),
|
|
1042
|
+
document.body
|
|
1043
|
+
)
|
|
1044
|
+
] })
|
|
1045
|
+
] }),
|
|
1046
|
+
/* @__PURE__ */ jsxs14("div", { className: "fi-flex-gap-sm", children: [
|
|
1047
|
+
showClear && /* @__PURE__ */ jsx19(
|
|
1048
|
+
"button",
|
|
1049
|
+
{
|
|
1050
|
+
onClick: () => onClearConversation?.(),
|
|
1051
|
+
className: `${buttonBaseClass} chat-toolbar-btn-danger hidden @md:flex`,
|
|
1052
|
+
title: "Limpiar conversaci\xF3n",
|
|
1053
|
+
"aria-label": "Limpiar conversaci\xF3n",
|
|
1054
|
+
children: /* @__PURE__ */ jsx19(Trash, { className: iconClass })
|
|
1055
|
+
}
|
|
1056
|
+
),
|
|
1057
|
+
showThinkingToggle && /* @__PURE__ */ jsx19(
|
|
1058
|
+
"button",
|
|
1059
|
+
{
|
|
1060
|
+
onClick: onShowThinkingToggle,
|
|
1061
|
+
className: `${buttonBaseClass} hidden @md:flex ${showThinking ? "chat-toolbar-btn-active" : ""}`,
|
|
1062
|
+
title: showThinking ? "Razonamiento visible (click para ocultar)" : "Razonamiento oculto (click para mostrar)",
|
|
1063
|
+
"aria-label": showThinking ? "Ocultar razonamiento del modelo" : "Mostrar razonamiento del modelo",
|
|
1064
|
+
children: /* @__PURE__ */ jsx19(Sparkles, { className: iconClass })
|
|
1065
|
+
}
|
|
1066
|
+
),
|
|
1067
|
+
showResponseMode && /* @__PURE__ */ jsx19(
|
|
1068
|
+
"button",
|
|
1069
|
+
{
|
|
1070
|
+
onClick: onResponseModeToggle,
|
|
1071
|
+
className: `${buttonBaseClass} ${responseMode === "concise" ? "fi-text-info hover:text-cyan-300" : "chat-toolbar-btn-success"}`,
|
|
1072
|
+
title: responseMode === "explanatory" ? "Modo: Explicativo (detallado)" : "Modo: Conciso (breve)",
|
|
1073
|
+
"aria-label": responseMode === "explanatory" ? "Cambiar a modo conciso" : "Cambiar a modo explicativo",
|
|
1074
|
+
children: responseMode === "explanatory" ? /* @__PURE__ */ jsx19(BookOpen, { className: iconClass }) : /* @__PURE__ */ jsx19(Zap, { className: iconClass })
|
|
1075
|
+
}
|
|
1076
|
+
),
|
|
1077
|
+
showVoice && /* @__PURE__ */ jsx19(
|
|
1078
|
+
VoiceMicButton,
|
|
1079
|
+
{
|
|
1080
|
+
isRecording: voiceRecording?.isRecording || false,
|
|
1081
|
+
isTranscribing: voiceRecording?.isTranscribing || false,
|
|
1082
|
+
audioLevel: voiceRecording?.audioLevel || 0,
|
|
1083
|
+
isSilent: voiceRecording?.isSilent ?? true,
|
|
1084
|
+
recordingTime: voiceRecording?.recordingTime || 0,
|
|
1085
|
+
onStart: onVoiceStart || (() => {
|
|
1086
|
+
}),
|
|
1087
|
+
onStop: onVoiceStop || (() => {
|
|
1088
|
+
})
|
|
1089
|
+
}
|
|
1090
|
+
),
|
|
1091
|
+
/* @__PURE__ */ jsx19(
|
|
1092
|
+
"button",
|
|
1093
|
+
{
|
|
1094
|
+
onClick: onSend,
|
|
1095
|
+
disabled: !canSend,
|
|
1096
|
+
className: `p-2.5 rounded-xl flex items-center justify-center flex-shrink-0 transition-all duration-200 ${canSend ? "bg-gradient-to-r from-amber-500 to-orange-500 text-slate-900 shadow-lg shadow-amber-500/25 hover:shadow-amber-500/40" : "bg-slate-800 text-slate-500 cursor-not-allowed"}`,
|
|
1097
|
+
"aria-label": "Enviar mensaje",
|
|
1098
|
+
children: sendLoading ? /* @__PURE__ */ jsx19(Loader211, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsx19(Send, { className: "h-4 w-4" })
|
|
1099
|
+
}
|
|
1100
|
+
)
|
|
1101
|
+
] })
|
|
1102
|
+
] });
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// src/shell/ChatFilePreview.tsx
|
|
1106
|
+
import {
|
|
1107
|
+
FileText,
|
|
1108
|
+
FileCode,
|
|
1109
|
+
Image as ImageIcon,
|
|
1110
|
+
File,
|
|
1111
|
+
X as X2,
|
|
1112
|
+
Loader2 as Loader212,
|
|
1113
|
+
CheckCircle,
|
|
1114
|
+
AlertCircle as AlertCircle4
|
|
1115
|
+
} from "lucide-react";
|
|
1116
|
+
import { Fragment as Fragment5, jsx as jsx20, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
1117
|
+
var FILE_ICONS = {
|
|
1118
|
+
"application/pdf": FileText,
|
|
1119
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": FileText,
|
|
1120
|
+
"application/msword": FileText,
|
|
1121
|
+
"text/plain": File,
|
|
1122
|
+
"text/markdown": FileCode,
|
|
1123
|
+
"image/png": ImageIcon,
|
|
1124
|
+
"image/jpeg": ImageIcon,
|
|
1125
|
+
"image/jpg": ImageIcon
|
|
1126
|
+
};
|
|
1127
|
+
function formatFileSize(bytes) {
|
|
1128
|
+
if (bytes === 0) return "0 B";
|
|
1129
|
+
const k = 1024;
|
|
1130
|
+
const sizes = ["B", "KB", "MB", "GB"];
|
|
1131
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
1132
|
+
return `${parseFloat((bytes / Math.pow(k, i)).toFixed(1))} ${sizes[i]}`;
|
|
1133
|
+
}
|
|
1134
|
+
function getFileIcon(file) {
|
|
1135
|
+
return FILE_ICONS[file.type] || File;
|
|
1136
|
+
}
|
|
1137
|
+
function ChatFilePreview({
|
|
1138
|
+
file,
|
|
1139
|
+
status,
|
|
1140
|
+
progress = 0,
|
|
1141
|
+
error,
|
|
1142
|
+
onCancel
|
|
1143
|
+
}) {
|
|
1144
|
+
const FileIcon = getFileIcon(file);
|
|
1145
|
+
const isCompleted = status === "indexed";
|
|
1146
|
+
const isError = status === "error";
|
|
1147
|
+
const isUploading = status === "uploading";
|
|
1148
|
+
const isProcessing = status === "processing" || status === "pending_instructions";
|
|
1149
|
+
return /* @__PURE__ */ jsxs15("div", { className: `
|
|
1150
|
+
flex items-center gap-3 p-3 rounded-xl border
|
|
1151
|
+
${isError ? "bg-red-900/20 border-red-700/50" : isCompleted ? "bg-emerald-900/20 border-emerald-700/50" : "bg-slate-800/80 border-slate-700/50"}
|
|
1152
|
+
transition-colors duration-200
|
|
1153
|
+
`, children: [
|
|
1154
|
+
/* @__PURE__ */ jsx20("div", { className: `
|
|
1155
|
+
p-2 rounded-lg
|
|
1156
|
+
${isError ? "bg-red-900/50" : isCompleted ? "bg-emerald-900/50" : "bg-slate-700"}
|
|
1157
|
+
`, children: isProcessing ? /* @__PURE__ */ jsx20(Loader212, { className: "w-5 h-5 fi-text-primary animate-spin" }) : isCompleted ? /* @__PURE__ */ jsx20(CheckCircle, { className: "w-5 h-5 fi-text-success" }) : isError ? /* @__PURE__ */ jsx20(AlertCircle4, { className: "w-5 h-5 fi-text-error" }) : /* @__PURE__ */ jsx20(FileIcon, { className: "w-5 h-5 fi-text" }) }),
|
|
1158
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex-1 min-w-0", children: [
|
|
1159
|
+
/* @__PURE__ */ jsx20("p", { className: "fi-title-sm-medium truncate", title: file.name, children: file.name }),
|
|
1160
|
+
/* @__PURE__ */ jsxs15("div", { className: "flex items-center gap-2 fi-text-xs", children: [
|
|
1161
|
+
/* @__PURE__ */ jsx20("span", { children: formatFileSize(file.size) }),
|
|
1162
|
+
isUploading && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
1163
|
+
/* @__PURE__ */ jsx20("span", { children: "-" }),
|
|
1164
|
+
/* @__PURE__ */ jsx20("span", { className: "fi-text-primary", children: progress < 100 ? `Subiendo... ${progress}%` : "Completado" })
|
|
1165
|
+
] }),
|
|
1166
|
+
isProcessing && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
1167
|
+
/* @__PURE__ */ jsx20("span", { children: "-" }),
|
|
1168
|
+
/* @__PURE__ */ jsx20("span", { className: "fi-text-primary", children: "Procesando..." })
|
|
1169
|
+
] }),
|
|
1170
|
+
isCompleted && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
1171
|
+
/* @__PURE__ */ jsx20("span", { children: "-" }),
|
|
1172
|
+
/* @__PURE__ */ jsx20("span", { className: "chat-file-status-indexed", children: "Indexado" })
|
|
1173
|
+
] }),
|
|
1174
|
+
isError && error && /* @__PURE__ */ jsxs15(Fragment5, { children: [
|
|
1175
|
+
/* @__PURE__ */ jsx20("span", { children: "-" }),
|
|
1176
|
+
/* @__PURE__ */ jsx20("span", { className: "fi-text-error truncate", title: error, children: error })
|
|
1177
|
+
] })
|
|
1178
|
+
] }),
|
|
1179
|
+
isUploading && /* @__PURE__ */ jsx20("div", { className: "mt-2 h-1.5 bg-slate-700 rounded-full overflow-hidden", children: /* @__PURE__ */ jsx20(
|
|
1180
|
+
"div",
|
|
1181
|
+
{
|
|
1182
|
+
className: "fi-progress-bar duration-300",
|
|
1183
|
+
style: { width: `${progress}%` }
|
|
1184
|
+
}
|
|
1185
|
+
) })
|
|
1186
|
+
] }),
|
|
1187
|
+
!isCompleted && !isProcessing && /* @__PURE__ */ jsx20(
|
|
1188
|
+
"button",
|
|
1189
|
+
{
|
|
1190
|
+
type: "button",
|
|
1191
|
+
onClick: onCancel,
|
|
1192
|
+
className: "fi-btn-ghost fi-btn-sm fi-hover-bg",
|
|
1193
|
+
"aria-label": "Cancelar",
|
|
1194
|
+
title: "Cancelar",
|
|
1195
|
+
children: /* @__PURE__ */ jsx20(X2, { className: "h-4 w-4" })
|
|
1196
|
+
}
|
|
1197
|
+
)
|
|
1198
|
+
] });
|
|
1199
|
+
}
|
|
1200
|
+
|
|
1201
|
+
// src/shell/ChatStartScreen.tsx
|
|
1202
|
+
import { Download, MessageSquareText, Monitor, Shield, Sparkles as Sparkles2 } from "lucide-react";
|
|
1203
|
+
import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
1204
|
+
function ChatStartScreen({
|
|
1205
|
+
isAuthenticated,
|
|
1206
|
+
userName,
|
|
1207
|
+
onStart,
|
|
1208
|
+
onLogin: _onLogin,
|
|
1209
|
+
onNavigate,
|
|
1210
|
+
isLoading = false
|
|
1211
|
+
}) {
|
|
1212
|
+
if (!isAuthenticated) {
|
|
1213
|
+
return /* @__PURE__ */ jsx21("div", { className: "chat-start-screen", children: /* @__PURE__ */ jsxs16("div", { className: "chat-start-container", children: [
|
|
1214
|
+
/* @__PURE__ */ jsx21("div", { className: "flex justify-center", children: /* @__PURE__ */ jsx21("div", { className: "chat-start-icon", children: /* @__PURE__ */ jsx21(Monitor, { className: "fi-icon-xl text-purple-400" }) }) }),
|
|
1215
|
+
/* @__PURE__ */ jsxs16("div", { className: "fi-stack-sm", children: [
|
|
1216
|
+
/* @__PURE__ */ jsx21("h3", { className: "chat-start-title", children: "\xA1Pru\xE9balo en tu escritorio!" }),
|
|
1217
|
+
/* @__PURE__ */ jsx21("p", { className: "chat-start-subtitle", children: "IA offline para tu desarrollo profesional. Licencias piloto gratuitas disponibles. \xA1Descarga la tuya!" })
|
|
1218
|
+
] }),
|
|
1219
|
+
/* @__PURE__ */ jsxs16(
|
|
1220
|
+
"button",
|
|
1221
|
+
{
|
|
1222
|
+
type: "button",
|
|
1223
|
+
onClick: () => onNavigate?.("downloads"),
|
|
1224
|
+
className: "chat-start-btn-login",
|
|
1225
|
+
children: [
|
|
1226
|
+
/* @__PURE__ */ jsx21(Download, { className: "fi-icon-md" }),
|
|
1227
|
+
"Ir a Descargas"
|
|
1228
|
+
]
|
|
1229
|
+
}
|
|
1230
|
+
),
|
|
1231
|
+
/* @__PURE__ */ jsx21("p", { className: "chat-start-hint", children: "100% privado, funciona sin internet" })
|
|
1232
|
+
] }) });
|
|
1233
|
+
}
|
|
1234
|
+
return /* @__PURE__ */ jsx21("div", { className: "chat-start-screen", children: /* @__PURE__ */ jsxs16("div", { className: "chat-start-container", children: [
|
|
1235
|
+
/* @__PURE__ */ jsx21("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ jsx21("div", { className: "chat-start-icon-large", children: /* @__PURE__ */ jsx21(Sparkles2, { className: "w-10 h-10 fi-text-purple" }) }) }),
|
|
1236
|
+
/* @__PURE__ */ jsxs16("div", { className: "fi-stack-sm", children: [
|
|
1237
|
+
/* @__PURE__ */ jsxs16("h3", { className: "chat-start-title-large", children: [
|
|
1238
|
+
"Hola, ",
|
|
1239
|
+
userName?.split(" ")[0] || "Doctor"
|
|
1240
|
+
] }),
|
|
1241
|
+
/* @__PURE__ */ jsx21("p", { className: "chat-start-subtitle", children: "Soy tu asistente de Free Intelligence. Estoy listo para ayudarte con consultas m\xE9dicas, notas SOAP y an\xE1lisis cl\xEDnicos." })
|
|
1242
|
+
] }),
|
|
1243
|
+
/* @__PURE__ */ jsxs16("div", { className: "chat-start-features", children: [
|
|
1244
|
+
/* @__PURE__ */ jsxs16("div", { className: "chat-start-feature", children: [
|
|
1245
|
+
/* @__PURE__ */ jsx21(MessageSquareText, { className: "w-4 h-4 fi-text-purple flex-shrink-0" }),
|
|
1246
|
+
/* @__PURE__ */ jsx21("span", { children: "Conversaci\xF3n privada y segura" })
|
|
1247
|
+
] }),
|
|
1248
|
+
/* @__PURE__ */ jsxs16("div", { className: "chat-start-feature", children: [
|
|
1249
|
+
/* @__PURE__ */ jsx21(Shield, { className: "w-4 h-4 fi-text-green flex-shrink-0" }),
|
|
1250
|
+
/* @__PURE__ */ jsx21("span", { children: "Datos encriptados localmente" })
|
|
1251
|
+
] })
|
|
1252
|
+
] }),
|
|
1253
|
+
/* @__PURE__ */ jsx21("button", { onClick: onStart, disabled: isLoading, className: "chat-start-btn-begin", children: isLoading ? /* @__PURE__ */ jsxs16(Fragment6, { children: [
|
|
1254
|
+
/* @__PURE__ */ jsx21("div", { className: "chat-start-spinner" }),
|
|
1255
|
+
"Iniciando..."
|
|
1256
|
+
] }) : /* @__PURE__ */ jsxs16(Fragment6, { children: [
|
|
1257
|
+
/* @__PURE__ */ jsx21(MessageSquareText, { className: "w-5 h-5" }),
|
|
1258
|
+
"Comenzar conversaci\xF3n"
|
|
1259
|
+
] }) }),
|
|
1260
|
+
/* @__PURE__ */ jsx21("p", { className: "chat-start-hint", children: "Presiona para iniciar una nueva conversaci\xF3n" })
|
|
1261
|
+
] }) });
|
|
1262
|
+
}
|
|
1263
|
+
|
|
1264
|
+
// src/shell/ChatContent.tsx
|
|
1265
|
+
import { jsx as jsx22, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
1266
|
+
function ChatContent({
|
|
1267
|
+
config,
|
|
1268
|
+
embedded,
|
|
1269
|
+
isAuthenticated,
|
|
1270
|
+
userName,
|
|
1271
|
+
viewMode,
|
|
1272
|
+
isHistoryOpen,
|
|
1273
|
+
isStartingConversation,
|
|
1274
|
+
messageCount,
|
|
1275
|
+
loading,
|
|
1276
|
+
isTyping,
|
|
1277
|
+
loadingInitial,
|
|
1278
|
+
customEmptyState,
|
|
1279
|
+
customQuickReplies,
|
|
1280
|
+
message,
|
|
1281
|
+
responseMode,
|
|
1282
|
+
selectedPersona,
|
|
1283
|
+
personaName,
|
|
1284
|
+
showThinking = true,
|
|
1285
|
+
voiceState,
|
|
1286
|
+
uploadFile,
|
|
1287
|
+
uploadStatus,
|
|
1288
|
+
isUploadActive,
|
|
1289
|
+
onNavigate,
|
|
1290
|
+
onModeChange,
|
|
1291
|
+
onMinimize,
|
|
1292
|
+
onMaximize,
|
|
1293
|
+
onToggleDenseMode,
|
|
1294
|
+
onClose,
|
|
1295
|
+
onHistoryOpen,
|
|
1296
|
+
onHistoryClose,
|
|
1297
|
+
onStartConversation,
|
|
1298
|
+
onLogin,
|
|
1299
|
+
onMessageChange,
|
|
1300
|
+
onSend,
|
|
1301
|
+
onResponseModeToggle,
|
|
1302
|
+
onShowThinkingToggle,
|
|
1303
|
+
onPersonaChange: _onPersonaChange,
|
|
1304
|
+
onClearConversation,
|
|
1305
|
+
onVoiceStart,
|
|
1306
|
+
onVoiceStop,
|
|
1307
|
+
onAttach,
|
|
1308
|
+
onCancelUpload,
|
|
1309
|
+
onCopyCurl,
|
|
1310
|
+
personaSelector,
|
|
1311
|
+
renderHistory,
|
|
1312
|
+
renderMessages
|
|
1313
|
+
}) {
|
|
1314
|
+
const dynamicPlaceholder = personaName ? `Escribe a ${personaName}...` : "Escribe tu mensaje...";
|
|
1315
|
+
const showVoice = typeof onVoiceStart === "function";
|
|
1316
|
+
const showAttach = typeof onAttach === "function";
|
|
1317
|
+
const showResponseMode = typeof onResponseModeToggle === "function";
|
|
1318
|
+
const showThinkingToggle = typeof onShowThinkingToggle === "function";
|
|
1319
|
+
const showClear = typeof onClearConversation === "function";
|
|
1320
|
+
const showPersonaSelector = personaSelector != null;
|
|
1321
|
+
return /* @__PURE__ */ jsxs17("div", { className: "relative flex h-full flex-1 flex-col overflow-hidden", children: [
|
|
1322
|
+
!isHistoryOpen && /* @__PURE__ */ jsxs17(
|
|
1323
|
+
ChatWidgetContainer,
|
|
1324
|
+
{
|
|
1325
|
+
mode: viewMode,
|
|
1326
|
+
title: config.title,
|
|
1327
|
+
embedded,
|
|
1328
|
+
onModeChange,
|
|
1329
|
+
children: [
|
|
1330
|
+
viewMode !== "dense" && !embedded && /* @__PURE__ */ jsx22(
|
|
1331
|
+
ChatWidgetHeader,
|
|
1332
|
+
{
|
|
1333
|
+
title: config.title,
|
|
1334
|
+
subtitle: config.subtitle,
|
|
1335
|
+
backgroundClass: config.theme.background.header,
|
|
1336
|
+
mode: viewMode,
|
|
1337
|
+
showControls: !embedded,
|
|
1338
|
+
onNavigate,
|
|
1339
|
+
onMinimize,
|
|
1340
|
+
onMaximize,
|
|
1341
|
+
onToggleDenseMode,
|
|
1342
|
+
onClose,
|
|
1343
|
+
onHistorySearch: onHistoryOpen
|
|
1344
|
+
}
|
|
1345
|
+
),
|
|
1346
|
+
messageCount === 0 && loadingInitial ? /* @__PURE__ */ jsx22("div", { className: "flex h-full items-center justify-center", children: /* @__PURE__ */ jsx22(Loader213, { className: "h-8 w-8 animate-spin text-slate-400" }) }) : messageCount === 0 && !isTyping && customEmptyState ? customEmptyState : messageCount === 0 && !isTyping ? /* @__PURE__ */ jsx22(
|
|
1347
|
+
ChatStartScreen,
|
|
1348
|
+
{
|
|
1349
|
+
isAuthenticated,
|
|
1350
|
+
userName,
|
|
1351
|
+
onStart: onStartConversation,
|
|
1352
|
+
onLogin,
|
|
1353
|
+
onNavigate,
|
|
1354
|
+
isLoading: isStartingConversation
|
|
1355
|
+
}
|
|
1356
|
+
) : renderMessages?.({ viewMode }),
|
|
1357
|
+
customQuickReplies,
|
|
1358
|
+
viewMode !== "dense" && /* @__PURE__ */ jsx22("div", { className: "chat-input-wrapper", children: /* @__PURE__ */ jsxs17("div", { className: "chat-input-floating-box", children: [
|
|
1359
|
+
isUploadActive && uploadFile && /* @__PURE__ */ jsx22(
|
|
1360
|
+
ChatFilePreview,
|
|
1361
|
+
{
|
|
1362
|
+
file: uploadFile,
|
|
1363
|
+
status: uploadStatus ?? "selecting",
|
|
1364
|
+
onCancel: onCancelUpload ?? (() => {
|
|
1365
|
+
})
|
|
1366
|
+
}
|
|
1367
|
+
),
|
|
1368
|
+
/* @__PURE__ */ jsx22(
|
|
1369
|
+
Composer,
|
|
1370
|
+
{
|
|
1371
|
+
message,
|
|
1372
|
+
loading,
|
|
1373
|
+
placeholder: dynamicPlaceholder,
|
|
1374
|
+
onMessageChange,
|
|
1375
|
+
onSend,
|
|
1376
|
+
maxRows: 5,
|
|
1377
|
+
areaClassName: "chat-input-area-top",
|
|
1378
|
+
wrapperClassName: "flex-1",
|
|
1379
|
+
textareaClassName: "chat-textarea"
|
|
1380
|
+
}
|
|
1381
|
+
),
|
|
1382
|
+
/* @__PURE__ */ jsx22(
|
|
1383
|
+
ChatToolbar,
|
|
1384
|
+
{
|
|
1385
|
+
responseMode,
|
|
1386
|
+
selectedPersona,
|
|
1387
|
+
showThinking,
|
|
1388
|
+
voiceRecording: voiceState,
|
|
1389
|
+
personaSelector,
|
|
1390
|
+
showAttach,
|
|
1391
|
+
showLanguage: false,
|
|
1392
|
+
showFormatting: false,
|
|
1393
|
+
showResponseMode,
|
|
1394
|
+
showVoice,
|
|
1395
|
+
showPersonaSelector,
|
|
1396
|
+
showThinkingToggle,
|
|
1397
|
+
showClear,
|
|
1398
|
+
showCopyCurl: typeof onCopyCurl === "function",
|
|
1399
|
+
onResponseModeToggle,
|
|
1400
|
+
onShowThinkingToggle,
|
|
1401
|
+
onClearConversation,
|
|
1402
|
+
onCopyCurl,
|
|
1403
|
+
onAttach,
|
|
1404
|
+
onVoiceStart,
|
|
1405
|
+
onVoiceStop,
|
|
1406
|
+
onSend,
|
|
1407
|
+
canSend: message.trim().length > 0 && !loading,
|
|
1408
|
+
sendLoading: loading
|
|
1409
|
+
}
|
|
1410
|
+
)
|
|
1411
|
+
] }) })
|
|
1412
|
+
]
|
|
1413
|
+
}
|
|
1414
|
+
),
|
|
1415
|
+
isHistoryOpen && renderHistory?.({ onClose: onHistoryClose })
|
|
1416
|
+
] });
|
|
1417
|
+
}
|
|
1418
|
+
|
|
1419
|
+
// src/shell/ChatWidget.tsx
|
|
1420
|
+
import { jsx as jsx23 } from "react/jsx-runtime";
|
|
1421
|
+
function ChatWidget({
|
|
1422
|
+
chatHook,
|
|
1423
|
+
config: customConfig,
|
|
1424
|
+
user,
|
|
1425
|
+
isAuthenticated = false,
|
|
1426
|
+
onLogin,
|
|
1427
|
+
onNavigate,
|
|
1428
|
+
isMobile: isMobileProp,
|
|
1429
|
+
initialOpen = false,
|
|
1430
|
+
initialMode = "normal",
|
|
1431
|
+
embedded = false,
|
|
1432
|
+
message,
|
|
1433
|
+
onMessageChange,
|
|
1434
|
+
onSend,
|
|
1435
|
+
responseMode,
|
|
1436
|
+
selectedPersona,
|
|
1437
|
+
personaName,
|
|
1438
|
+
showThinking,
|
|
1439
|
+
onResponseModeToggle,
|
|
1440
|
+
onShowThinkingToggle,
|
|
1441
|
+
onPersonaChange,
|
|
1442
|
+
onClearConversation,
|
|
1443
|
+
voiceState,
|
|
1444
|
+
onVoiceStart,
|
|
1445
|
+
onVoiceStop,
|
|
1446
|
+
uploadFile,
|
|
1447
|
+
uploadStatus,
|
|
1448
|
+
isUploadActive,
|
|
1449
|
+
onAttach,
|
|
1450
|
+
onCancelUpload,
|
|
1451
|
+
isStartingConversation = false,
|
|
1452
|
+
onStartConversation,
|
|
1453
|
+
personaSelector,
|
|
1454
|
+
renderHistory,
|
|
1455
|
+
renderMessages,
|
|
1456
|
+
onCopyCurl
|
|
1457
|
+
}) {
|
|
1458
|
+
const internalIsMobile = useMediaQuery(CHAT_BREAKPOINTS.mobile, { ssrMatch: false });
|
|
1459
|
+
const isMobile = isMobileProp ?? internalIsMobile;
|
|
1460
|
+
const config = mergeChatConfig(customConfig);
|
|
1461
|
+
const widgetState = useChatWidgetState({ initialOpen, initialMode });
|
|
1462
|
+
const messages = chatHook.messages;
|
|
1463
|
+
const messageCount = messages.length;
|
|
1464
|
+
const loading = chatHook.loading;
|
|
1465
|
+
const isTyping = chatHook.isTyping;
|
|
1466
|
+
const loadingInitial = chatHook.loadingInitial ?? false;
|
|
1467
|
+
const customEmptyState = chatHook.customEmptyState;
|
|
1468
|
+
const customQuickReplies = chatHook.customQuickReplies;
|
|
1469
|
+
const handleOpen = useCallback8(() => {
|
|
1470
|
+
widgetState.open();
|
|
1471
|
+
widgetState.onMessagesLoaded(messageCount > 0);
|
|
1472
|
+
}, [widgetState, messageCount]);
|
|
1473
|
+
if (!widgetState.isOpen) {
|
|
1474
|
+
if (embedded) return null;
|
|
1475
|
+
return /* @__PURE__ */ jsx23(FloatingButton, { onClick: handleOpen, isMobile });
|
|
1476
|
+
}
|
|
1477
|
+
return /* @__PURE__ */ jsx23(
|
|
1478
|
+
ChatContent,
|
|
1479
|
+
{
|
|
1480
|
+
config,
|
|
1481
|
+
embedded,
|
|
1482
|
+
isAuthenticated,
|
|
1483
|
+
userName: user?.name || void 0,
|
|
1484
|
+
viewMode: widgetState.viewMode,
|
|
1485
|
+
isHistoryOpen: widgetState.isHistoryOpen,
|
|
1486
|
+
isStartingConversation,
|
|
1487
|
+
messageCount,
|
|
1488
|
+
loading,
|
|
1489
|
+
isTyping,
|
|
1490
|
+
loadingInitial,
|
|
1491
|
+
customEmptyState,
|
|
1492
|
+
customQuickReplies,
|
|
1493
|
+
message,
|
|
1494
|
+
responseMode,
|
|
1495
|
+
selectedPersona,
|
|
1496
|
+
personaName,
|
|
1497
|
+
showThinking,
|
|
1498
|
+
voiceState,
|
|
1499
|
+
uploadFile,
|
|
1500
|
+
uploadStatus,
|
|
1501
|
+
isUploadActive,
|
|
1502
|
+
onNavigate,
|
|
1503
|
+
onModeChange: widgetState.setViewMode,
|
|
1504
|
+
onMinimize: widgetState.minimize,
|
|
1505
|
+
onMaximize: widgetState.maximize,
|
|
1506
|
+
onToggleDenseMode: widgetState.toggleDenseMode,
|
|
1507
|
+
onClose: widgetState.close,
|
|
1508
|
+
onHistoryOpen: widgetState.openHistory,
|
|
1509
|
+
onHistoryClose: widgetState.closeHistory,
|
|
1510
|
+
onStartConversation: onStartConversation ?? widgetState.startConversation,
|
|
1511
|
+
onLogin: onLogin ?? (() => {
|
|
1512
|
+
}),
|
|
1513
|
+
onMessageChange,
|
|
1514
|
+
onSend,
|
|
1515
|
+
onResponseModeToggle,
|
|
1516
|
+
onShowThinkingToggle,
|
|
1517
|
+
onPersonaChange,
|
|
1518
|
+
onClearConversation,
|
|
1519
|
+
onVoiceStart,
|
|
1520
|
+
onVoiceStop,
|
|
1521
|
+
onAttach,
|
|
1522
|
+
onCancelUpload,
|
|
1523
|
+
onCopyCurl,
|
|
1524
|
+
personaSelector,
|
|
1525
|
+
renderHistory,
|
|
1526
|
+
renderMessages
|
|
1527
|
+
}
|
|
1528
|
+
);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
// src/shell/ChatSurface.tsx
|
|
1532
|
+
import { jsx as jsx24 } from "react/jsx-runtime";
|
|
1533
|
+
function ChatSurface(props) {
|
|
1534
|
+
return /* @__PURE__ */ jsx24(
|
|
1535
|
+
ChatWidget,
|
|
1536
|
+
{
|
|
1537
|
+
...props,
|
|
1538
|
+
embedded: true,
|
|
1539
|
+
initialOpen: true,
|
|
1540
|
+
initialMode: "fullscreen"
|
|
1541
|
+
}
|
|
1542
|
+
);
|
|
1543
|
+
}
|
|
1544
|
+
export {
|
|
1545
|
+
CHAT_BREAKPOINTS,
|
|
1546
|
+
ChatContent,
|
|
1547
|
+
ChatFilePreview,
|
|
1548
|
+
ChatStartScreen,
|
|
1549
|
+
ChatSurface,
|
|
1550
|
+
ChatToolbar,
|
|
1551
|
+
ChatWidget,
|
|
1552
|
+
ChatWidgetContainer,
|
|
1553
|
+
ChatWidgetHeader,
|
|
1554
|
+
FloatingButton,
|
|
1555
|
+
clearMediaQueryCache,
|
|
1556
|
+
defaultAnimationConfig,
|
|
1557
|
+
defaultBehavior,
|
|
1558
|
+
defaultChatConfig,
|
|
1559
|
+
defaultTheme,
|
|
1560
|
+
defaultTimestampConfig,
|
|
1561
|
+
mergeChatConfig,
|
|
1562
|
+
useBreakpoints,
|
|
1563
|
+
useChatWidgetState,
|
|
1564
|
+
useMediaQuery
|
|
1565
|
+
};
|
|
1566
|
+
//# sourceMappingURL=index.js.map
|