import * as React from 'react'
import * as LabelPrimitive from '@radix-ui/react-label'
import { cn } from '@/lib/utils'

export interface LabelProps extends React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> {
  /** Font weight: 'normal' or 'medium' */
  weight?: 'normal' | 'medium'
}

const weightClass = {
  normal: 'font-normal',
  medium: 'font-medium',
} as const

const Label = React.forwardRef<
  React.ElementRef<typeof LabelPrimitive.Root>,
  LabelProps
>(({ className, weight = 'medium', ...props }, ref) => (
  <LabelPrimitive.Root
    ref={ref}
    className={cn(
      'flex items-center gap-2 text-sm leading-none text-text',
      weightClass[weight],
      'peer-disabled:cursor-not-allowed peer-disabled:opacity-50',
      'has-[[disabled]]:cursor-not-allowed has-[[disabled]]:opacity-50',
      className,
    )}
    {...props}
  />
))
Label.displayName = LabelPrimitive.Root.displayName

export { Label }
