// AUTO-GENERATED by scripts/generate-wrappers.mjs — do not edit by hand.
// Source: packages/core/manifest.json (component "carousel").
import type { ElementType, ReactNode } from 'react';
import { Carousel as CarouselController, type CarouselOptions } from '@42/core/carousel';
import { C42 } from '../C42';

const DEFAULT_HTML: string | null = "<div data-c42-carousel-viewport>\n    <div data-c42-carousel-track>\n      <div data-c42-carousel-slide>One</div>\n      <div data-c42-carousel-slide>Two</div>\n      <div data-c42-carousel-slide>Three</div>\n    </div>\n  </div>\n  <button data-c42-carousel-prev aria-label=\"Previous slide\">‹</button>\n  <button data-c42-carousel-next aria-label=\"Next slide\">›</button>\n  <div data-c42-carousel-dots></div>";

export interface CarouselProps extends Partial<CarouselOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `carousel:change` — detail: `{ index, previousIndex }` */
  onChange?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function Carousel(props: CarouselProps) {
  const { as, className, children, onChange, defaultIndex, loop, axis, align, slidesToScroll, dragFree, swipe, autoplay, autoplayInterval, pauseOnHover, ...rest } = props;
  const options = { defaultIndex, loop, axis, align, slidesToScroll, dragFree, swipe, autoplay, autoplayInterval, pauseOnHover } as CarouselOptions;

  return (
    <C42
      controller={CarouselController}
      options={options}
      deps={[defaultIndex, loop, axis, align, slidesToScroll, dragFree, swipe, autoplay, autoplayInterval, pauseOnHover]}
      events={{
        'carousel:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-carousel': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
