import type { ReactNode } from 'react';
import {
  Button as ProductButton,
  type ButtonProps as ProductButtonProps,
} from './Primitives';

type LegacyButtonVariant = 'default' | 'outline' | 'ghost' | 'destructive' | 'subtle';

const variantMap: Record<LegacyButtonVariant, ProductButtonProps['variant']> = {
  default: 'primary',
  outline: 'outline',
  ghost: 'ghost',
  destructive: 'destructive',
  subtle: 'subtle',
};

export function Button({
  variant = 'default',
  children,
  ...props
}: Omit<ProductButtonProps, 'variant'> & {
  variant?: LegacyButtonVariant;
  children: ReactNode;
}) {
  return (
    <ProductButton variant={variantMap[variant]} {...props}>
      {children}
    </ProductButton>
  );
}
