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

const DEFAULT_HTML: string | null = "<div data-c42-accordion-item data-value=\"a\">\n    <button data-c42-accordion-trigger>Title</button>\n    <div data-c42-accordion-panel>Content</div>\n  </div>";

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

export function Accordion(props: AccordionProps) {
  const { as, className, children, onChange, multiple, collapsible, defaultValue, ...rest } = props;
  const options = { multiple, collapsible, defaultValue } as AccordionOptions;

  return (
    <C42
      controller={AccordionController}
      options={options}
      deps={[multiple, collapsible, defaultValue]}
      events={{
        'accordion:change': onChange,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-accordion': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
