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

const DEFAULT_HTML: string | null = "<button data-c42-tooltip-trigger>Hover me</button>\n  <div data-c42-tooltip-content>Tooltip text</div>";

export interface TooltipProps extends Partial<TooltipOptions> {
  /** Element/tag rendered as the controller root. Defaults to `"span"`. */
  as?: ElementType;
  className?: string;
  children?: ReactNode;
  /** Fired on `tooltip:open` — detail: `(no detail)` */
  onOpen?: (detail: unknown, event: CustomEvent) => void;
  /** Fired on `tooltip:close` — detail: `(no detail)` */
  onClose?: (detail: unknown, event: CustomEvent) => void;
  /** Extra props are forwarded to the rendered `<span>` element. */
  [key: string]: unknown;
}

export function Tooltip(props: TooltipProps) {
  const { as, className, children, onOpen, onClose, placement, offset, openDelay, closeDelay, ...rest } = props;
  const options = { placement, offset, openDelay, closeDelay } as TooltipOptions;

  return (
    <C42
      controller={TooltipController}
      options={options}
      deps={[placement, offset, openDelay, closeDelay]}
      events={{
        'tooltip:open': onOpen,
        'tooltip:close': onClose,
      }}
      as={(as as ElementType) ?? 'span'}
      className={className as string | undefined}
      html={DEFAULT_HTML ?? undefined}
      {...{ 'data-c42-tooltip': '' }}
      {...rest}
    >
      {children as ReactNode}
    </C42>
  );
}
