import * as React from "react";
import * as AccordionPrimitive from "@radix-ui/react-accordion";

import { cn } from "../../../../@/lib/utils";
import { MinusCircleIcon, PlusCircleIcon } from "lucide-react";

const Accordion = AccordionPrimitive.Root;

const AccordionItem = React.forwardRef<
  React.ElementRef<typeof AccordionPrimitive.Item>,
  React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
>(({ className, ...props }, ref) => (
  <AccordionPrimitive.Item
    ref={ref}
    className={cn("last:border-b-0 p-4 border-b border-gray-200", className)}
    {...props}
  />
));
AccordionItem.displayName = "AccordionItem";

const AccordionTrigger = React.forwardRef<
  React.ElementRef<typeof AccordionPrimitive.Trigger>,
  React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
>(({ className, children, ...props }, ref) => (
  <AccordionPrimitive.Header className="flex">
    <AccordionPrimitive.Trigger
      ref={ref}
      className={cn(
        "flex flex-1 items-center justify-between text-lg font-inter text-gray-900 font-medium duration-300 transition-all [&[data-state=open]>div>.dropdown-opened]:opacity-0 [&[data-state=open]]:mt-2 [&[data-state=closed]>div>.dropdown-closed]:opacity-0",
        className
      )}
      {...props}
    >
      {children}
      <div className="relative h-6 w-6">
        <div
          id=""
          className="dropdown-opened animate-in fade-in-50 animate-out fade-out-50 duration-500 top-0 absolute"
        >
          <PlusCircleIcon className="text-green-500" />
        </div>
        <div
          id=""
          className="dropdown-closed animate-in fade-in-50 animate-out fade-out-50 duration-500 top-0 absolute"
        >
          <MinusCircleIcon className="text-primary-700" />
        </div>
      </div>
    </AccordionPrimitive.Trigger>
  </AccordionPrimitive.Header>
));
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName;

const AccordionContent = React.forwardRef<
  React.ElementRef<typeof AccordionPrimitive.Content>,
  React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
>(({ className, children, ...props }, ref) => (
  <AccordionPrimitive.Content
    ref={ref}
    className={cn(
      "overflow-hidden text-sm text-gray-600 font-normal font-inter transition-all delay-300 data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",
      className
    )}
    {...props}
  >
    <div
      id=""
      className="pt-2 animate-in  fade-in-25 animate-out fade-out-0 delay-400 duration-400"
    >
      {children}
    </div>
  </AccordionPrimitive.Content>
));
AccordionContent.displayName = AccordionPrimitive.Content.displayName;

export { Accordion, AccordionItem, AccordionTrigger, AccordionContent };
