"use client" import { memo, useEffect } from "react" import type { NodePopoverProps } from "./types" import type { ViewportDocument, ViewportMemoryEntry } from "@/lib/viewport-graph-types" export const NodePopover = memo(function NodePopover({ node, x, y, onClose, containerBounds, }) { useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === "Escape") { onClose() } } window.addEventListener("keydown", handleKeyDown) return () => window.removeEventListener("keydown", handleKeyDown) }, [onClose]) const backdropStyle = containerBounds ? { left: `${containerBounds.left}px`, top: `${containerBounds.top}px`, width: `${containerBounds.width}px`, height: `${containerBounds.height}px`, } : undefined // Get content based on node type const getContent = () => { if (node.type === "document") { const doc = node.data as ViewportDocument return doc.summary || doc.title || "No content available" } const mem = node.data as ViewportMemoryEntry return mem.content || mem.summary || "No content available" } // Check if this is the latest/new item const isLatest = () => { if (node.type === "memory") { const mem = node.data as ViewportMemoryEntry return new Date(mem.createdAt).getTime() > Date.now() - 1000 * 60 * 60 * 24 } return false } // Get version info const getVersion = () => { return "v1" } return ( <>
e.stopPropagation()} className="fixed z-30 w-[400px] bg-[#0A1628]/95 backdrop-blur-xl border border-[#1E3A5F] rounded-2xl shadow-2xl overflow-hidden" style={{ left: `${x}px`, top: `${y}px`, }} > {/* Main content */}

{getContent()}

{/* Bottom bar with version and latest badge */}
{getVersion()} {isLatest() && (
Latest
)}
) })