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

const DEFAULT_HTML: string | null = "<span data-c42-alert-icon aria-hidden=\"true\">⚠</span>\n  <div data-c42-alert-content>\n    <strong data-c42-alert-title>Heads up</strong>\n    <p data-c42-alert-description>Your trial ends soon.</p>\n  </div>\n  <button data-c42-alert-dismiss aria-label=\"Dismiss\">×</button>";

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

export function Alert(props: AlertProps) {
  const { as, className, children, onDismiss, variant, role, ...rest } = props;
  const options = { variant, role } as AlertOptions;

  return (
    <C42
      controller={AlertController}
      options={options}
      deps={[variant, role]}
      events={{
        'alert:dismiss': onDismiss,
      }}
      as={(as as ElementType) ?? 'div'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-alert': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
