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

const DEFAULT_HTML: string | null = "<button data-c42-pagination-prev>Prev</button>\n  <div data-c42-pagination-list></div>\n  <button data-c42-pagination-next>Next</button>";

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

export function Pagination(props: PaginationProps) {
  const { as, className, children, onChange, total, page, siblingCount, boundaryCount, ...rest } = props;
  const options = { total, page, siblingCount, boundaryCount } as PaginationOptions;

  return (
    <C42
      controller={PaginationController}
      options={options}
      deps={[total, page, siblingCount, boundaryCount]}
      events={{
        'pagination:change': onChange,
      }}
      as={(as as ElementType) ?? 'nav'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-pagination': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
