import { cn } from '@/utils';
import * as AvatarPrimitive from '@radix-ui/react-avatar';
import * as React from 'react';
import styles from './BaseAvatar.module.css';

const BaseAvatar = React.forwardRef<
  React.ElementRef<typeof AvatarPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root>
>(({ className, ...props }, ref) => (
  <AvatarPrimitive.Root
    ref={ref}
    className={cn(styles.BaseAvatar, className)}
    {...props}
  />
));

const BaseAvatarImage = React.forwardRef<
  React.ElementRef<typeof AvatarPrimitive.Image>,
  React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image>
>(({ className, ...props }, ref) => (
  <AvatarPrimitive.Image
    ref={ref}
    className={cn(styles.BaseAvatarImage, className)}
    {...props}
  />
));

const BaseAvatarFallback = React.forwardRef<
  React.ElementRef<typeof AvatarPrimitive.Fallback>,
  React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback>
>(({ className, ...props }, ref) => (
  <AvatarPrimitive.Fallback
    ref={ref}
    className={cn(styles.BaseAvatarFallback, className)}
    {...props}
  />
));
BaseAvatar.displayName = AvatarPrimitive.Root.displayName;
BaseAvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
BaseAvatarImage.displayName = AvatarPrimitive.Image.displayName;

export { BaseAvatar, BaseAvatarImage, BaseAvatarFallback };
