'use client' import { motion } from 'motion/react' import { Layers, Zap, ArrowUpRight } from 'lucide-react' import { useLanguage } from '@/lib/i18n' import { DashboardWidgetTitleRow } from '@/components/dashboard-widget-title-row' interface Cluster { clusterId: number name?: string noteIds: string[] } interface BridgeNote { noteId: string bridgeScore: number clusterNames?: string[] note?: { id: string; title: string | null } } const CLUSTER_COLORS = ['#B91C1C', '#1D4ED8', '#047857', '#B45309', '#6D28D9', '#BE185D', '#0F766E'] const EASE = [0.16, 1, 0.3, 1] as const function clusterInk(hex: string): string { const n = hex.replace('#', '') const r = parseInt(n.slice(0, 2), 16) const g = parseInt(n.slice(2, 4), 16) const b = parseInt(n.slice(4, 6), 16) const y = (0.2126 * r + 0.7152 * g + 0.0722 * b) / 255 return y > 0.45 ? '#1C1917' : '#FAFAF9' } function clusterPoint(index: number, count: number): { x: number; y: number } { if (count === 1) return { x: 50, y: 42 } const angle = -Math.PI / 2 + (index * 2 * Math.PI) / count const rx = count <= 3 ? 28 : 36 const ry = count <= 3 ? 24 : 30 return { x: 50 + Math.cos(angle) * rx, y: 44 + Math.sin(angle) * ry } } export interface DashboardMindOrbitProps { clusters: Cluster[] bridgeNotes: BridgeNote[] loading?: boolean onOpenInsights: () => void onOpenCluster?: (clusterId: number) => void onNoteSelect: (id: string) => void prefersReducedMotion?: boolean } export function DashboardMindOrbit({ clusters, bridgeNotes, loading, onOpenInsights, onOpenCluster, onNoteSelect, prefersReducedMotion, }: DashboardMindOrbitProps) { const { t } = useLanguage() const topClusters = [...clusters] .sort((a, b) => b.noteIds.length - a.noteIds.length) .slice(0, 5) const maxCount = topClusters[0]?.noteIds.length || 1 const topBridge = bridgeNotes[0] const reduced = !!prefersReducedMotion const points = topClusters.map((_, idx) => clusterPoint(idx, topClusters.length)) if (loading) { return
} if (topClusters.length === 0) { return ( ) } return ({topBridge.note.title || t('homeDashboard.untitled')}
{t('homeDashboard.bridgeNote')}