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

const DEFAULT_HTML: string | null = "<div data-c42-calendar-header>\n    <button data-c42-calendar-prev aria-label=\"Previous\">‹</button>\n    <button data-c42-calendar-today>Today</button>\n    <button data-c42-calendar-next aria-label=\"Next\">›</button>\n    <span data-c42-calendar-title></span>\n    <button data-c42-calendar-view=\"month\">Month</button>\n    <button data-c42-calendar-view=\"week\">Week</button>\n    <button data-c42-calendar-view=\"day\">Day</button>\n  </div>\n  <div data-c42-calendar-grid></div>";

export interface CalendarProps extends Partial<CalendarOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"div"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `calendar:select` — detail: `{ date, dateKey }` */
  onSelect?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `calendar:viewchange` — detail: `{ view }` */
  onViewchange?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `calendar:navigate` — detail: `{ date, view }` */
  onNavigate?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `calendar:eventclick` — detail: `{ id, event }` */
  onEventclick?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `calendar:eventmove` — detail: `{ id, event, start, end }` */
  onEventmove?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<div>` element. */
  [key: string]: unknown;
}

export function Calendar(props: CalendarProps) {
  const { as, className, children, onSelect, onViewchange, onNavigate, onEventclick, onEventmove, defaultDate, view, weekStartsOn, events, locale, ...rest } = props;
  const options = { defaultDate, view, weekStartsOn, events, locale } as CalendarOptions;

  return (
    <C42
      controller={CalendarController}
      options={options}
      deps={[defaultDate, view, weekStartsOn, events, locale]}
      events={{
        'calendar:select': onSelect,
        'calendar:viewchange': onViewchange,
        'calendar:navigate': onNavigate,
        'calendar:eventclick': onEventclick,
        'calendar:eventmove': onEventmove,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-calendar': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
