'use client' import { type ReactNode } from 'react' import { motion, AnimatePresence, useReducedMotion } from 'motion/react' import { X, Maximize2, Loader2 } from 'lucide-react' import { useLanguage } from '@/lib/i18n' import type { Note } from '@/lib/types' import { NotePeekContent } from './note-peek-content' interface NotePeekPanelProps { note: Note | null blockId?: string loading?: boolean mode: 'overlay' | 'inline' onClose: () => void onOpenFully?: (note: Note) => void labelKey?: string renderContent?: (note: Note, blockId?: string) => ReactNode } export function NotePeekPanel({ note, blockId, loading = false, mode, onClose, onOpenFully, labelKey = 'notePeek.label', renderContent, }: NotePeekPanelProps) { const { t, language } = useLanguage() const isRtl = language === 'fa' || language === 'ar' const prefersReducedMotion = useReducedMotion() const isOpen = note !== null || loading const spring = prefersReducedMotion ? { duration: 0 } : { type: 'spring' as const, stiffness: 340, damping: 34 } const content = ( <>
{loading ? (t('notePeek.loading') || 'Loading…') : (note?.title || t('notePeek.untitled') || t('insightsView.unknownNote'))}
{onOpenFully && note && ( )}
{loading ? (
) : note ? (
{renderContent ? ( renderContent(note, blockId) ) : ( <>

{note.title || t('notePeek.untitled') || 'Untitled'}

)}
) : null}
) if (mode === 'overlay') { return ( {isOpen && ( {content} )} ) } // inline mode return ( {isOpen && ( {content} )} ) }