"use client"; import { useEffect, useRef, useState } from "react"; import { Check, Copy } from "lucide-react"; import { cn } from "@/lib/utils"; interface CopyButtonProps { text: string; className?: string; } export function CopyButton({ text, className }: CopyButtonProps) { const [copied, setCopied] = useState(false); const timeoutRef = useRef | null>(null); useEffect(() => { return () => { if (timeoutRef.current) clearTimeout(timeoutRef.current); }; }, []); const handleCopy = async () => { if (copied) return; try { await navigator.clipboard.writeText(text); setCopied(true); timeoutRef.current = setTimeout(() => setCopied(false), 1500); } catch { // clipboard unavailable — silently no-op } }; return ( ); }