/**
 * 文本块组件
 */

import { cn } from '@/lib/utils';
import type { ComponentPropsMap, RenderContext } from '../types';

interface TextBlockProps {
  props: ComponentPropsMap['text'];
  context: RenderContext;
}

export function TextBlock({ props }: TextBlockProps) {
  const { content, variant = 'body' } = props;

  const variantClass = {
    h1: 'text-3xl font-bold tracking-tight',
    h2: 'text-2xl font-semibold tracking-tight',
    h3: 'text-xl font-semibold',
    h4: 'text-lg font-medium',
    body: 'text-base',
    caption: 'text-sm',
    muted: 'text-sm text-muted-foreground',
  };

  const Tag = variant.startsWith('h') ? variant as keyof JSX.IntrinsicElements : 'p';

  return (
    <Tag className={cn(variantClass[variant])}>
      {content}
    </Tag>
  );
}
