'use client';

import { Copy } from 'lucide-react';
import {
  ContextMenu,
  ContextMenuContent,
  ContextMenuItem,
  ContextMenuTrigger
} from '@/components/ui/context-menu';

interface BotChatMessageContextMenuProps {
  text?: string;
  onCopy?: () => void;
  children: React.ReactNode;
}

export function BotChatMessageContextMenu({ text, onCopy, children }: BotChatMessageContextMenuProps) {
  const copyText = text?.trim();

  return (
    <ContextMenu>
      <ContextMenuTrigger asChild>{children}</ContextMenuTrigger>
      <ContextMenuContent className="min-w-[200px]">
        {copyText ? (
          <ContextMenuItem
            onClick={() => {
              void navigator.clipboard.writeText(copyText);
              onCopy?.();
            }}
          >
            <Copy className="h-4 w-4" />
            Копировать текст
          </ContextMenuItem>
        ) : null}
      </ContextMenuContent>
    </ContextMenu>
  );
}
