/**
 * Must be imported from the core package.
 * @see https://www.embla-carousel.com/api/methods/#typescript
 */
import type { EmblaCarouselType } from "embla-carousel"
import type useEmblaCarousel from "embla-carousel-react"
import type { PropsWithChildren } from "react"

export type CarouselApi = EmblaCarouselType
type UseCarouselParameters = Parameters<typeof useEmblaCarousel>
type CarouselOptions = UseCarouselParameters[0]
type CarouselPlugin = UseCarouselParameters[1]

export interface CarouselProps extends PropsWithChildren {
  opts?: CarouselOptions
  plugins?: CarouselPlugin
  setApi?: (api: CarouselApi) => void
  className?: string
  onScrollSelect?: (idx: number) => void
  scrollToIdx?: number
  align?: "start" | "center"
}

export interface CarouselContextProps extends Omit<CarouselProps, "className"> {
  carouselRef: ReturnType<typeof useEmblaCarousel>[0]
  api: ReturnType<typeof useEmblaCarousel>[1]
  scrollPrev: () => void
  scrollNext: () => void
  canScrollPrev: () => boolean
  canScrollNext: () => boolean
  selectedIndex: number
}

export interface CarouselButtonProps {
  className?: string
}
