import React, { useEffect } from 'react';
import { motion } from 'framer-motion';
import { ArrowUpRight, Globe } from 'lucide-react';
import { convertRemToPixels } from '@/lib/utils';
import { SpaceIcon } from '@/assets/Memories';
import Markdown from 'react-markdown';
export function ChatAnswer({
children: message,
sources,
loading = false,
}: {
children: string;
sources?: string[];
loading?: boolean;
}) {
return (
{loading ? (
) : (
{message}
)}
{!loading && sources && sources?.length > 0 && (
<>
Related Memories
{sources?.map((source) => (
{source}
))}
>
)}
);
}
export function ChatQuestion({ children }: { children: string }) {
return (
200 ? 'text-xl' : 'text-2xl'}`}
>
{children}
);
}
export function ChatMessage({
children,
isLast = false,
index,
}: {
children: React.ReactNode | React.ReactNode[];
isLast?: boolean;
index: number;
}) {
const messageRef = React.useRef(null);
useEffect(() => {
if (!isLast) return;
console.log(
'last',
messageRef.current?.offsetTop,
messageRef.current?.parentElement,
);
messageRef.current?.parentElement?.scrollTo({
top: messageRef.current?.offsetTop,
behavior: 'smooth',
});
}, []);
return (
{children}
);
}
function MessageSkeleton() {
return (
);
}