import React from "react";
import { ExternalLink } from "lucide-react";
import SquarePreviewFrame from "./SquarePreviewFrame";
import { domainFromUrl, faviconUrl, resolveSearchResultPreview } from "../lib/sitePreview";
/** Carte résultat de recherche avec miniature / favicon / extrait — pas d'iframe. */
export default function SearchResultPreview({
url,
title,
subtitle,
snippet,
className = "",
testId = "search-result-preview",
linked = true,
}) {
if (!url) return null;
const resolved = resolveSearchResultPreview(url, { snippet });
const domain = domainFromUrl(url);
const displayTitle = title || domain || url;
const displaySubtitle = subtitle || domain || url;
const imageFallback = faviconUrl(url);
const frame = (
<>
{resolved.kind === "image" && (