"use client"
import { cn } from "@lib/utils"
import {
type ChatMemoryCard,
getMemoryCardDisplay,
} from "@/lib/chat-search-memory-results"
import { dmSansClassName } from "@/lib/fonts"
type CardTone = "sidebar" | "input"
function RelevancyScore({ score }: { score: number }) {
return (
Relevancy score: {(score * 100).toFixed(1)}%
)
}
export function MemorySearchResultCard({
result,
tone,
}: {
result: ChatMemoryCard
tone: CardTone
}) {
const { title, body } = getMemoryCardDisplay(result)
const isClickable =
result.url &&
(result.url.startsWith("http://") || result.url.startsWith("https://"))
const textBlock = (
{title ? (
{title}
) : null}
{body || "—"}
{result.url ? (
{result.url}
) : null}
)
const column = (
<>
{textBlock}
{result.score != null ? : null}
>
)
if (isClickable) {
const linkClass =
tone === "sidebar"
? "flex h-full min-h-0 flex-col rounded-md border border-white/10 bg-white/5 p-2 transition-colors hover:bg-white/10"
: "flex h-full min-h-0 flex-col rounded-md border border-[#525D6E]/20 bg-[#0C1829]/50 p-2 transition-colors hover:bg-[#0C1829]/70"
return (
{column}
)
}
const solidClass =
tone === "sidebar"
? cn(
"flex h-full min-h-0 flex-col rounded-xl bg-[#0C1829] p-1",
dmSansClassName(),
)
: "flex h-full min-h-0 flex-col rounded-xl bg-[#0C1829] p-1"
return {column}
}