import * as React from "react"
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
import { Check } from "lucide-react"

import { cn } from "@/lib/utils"

const Checkbox = React.forwardRef<
  React.ElementRef<typeof CheckboxPrimitive.Root>,
  React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
  <CheckboxPrimitive.Root
    ref={ref}
    className={cn(
      "smx-grid smx-place-content-center smx-peer smx-h-4 smx-w-4 smx-shrink-0 smx-rounded-sm smx-border smx-border-primary smx-ring-offset-background focus-visible:smx-outline-none focus-visible:smx-ring-2 focus-visible:smx-ring-ring focus-visible:smx-ring-offset-2 disabled:smx-cursor-not-allowed disabled:smx-opacity-50 data-[state=checked]:smx-bg-primary data-[state=checked]:smx-text-primary-foreground",
      className
    )}
    {...props}
  >
    <CheckboxPrimitive.Indicator
      className={cn("smx-grid smx-place-content-center smx-text-current")}
    >
      <Check className="smx-h-4 smx-w-4" />
    </CheckboxPrimitive.Indicator>
  </CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName

export { Checkbox }
