import { SvelteComponentTyped } from "svelte";
import type { SvelteHTMLElements } from "svelte/elements";

type $RestProps = SvelteHTMLElements["a"];

type $Props<Icon = any> = {
  /**
   * Specify the `href` attribute to render an anchor.
   * Omit it to render a button (for actions like "Log out" or "Change theme").
   * @default undefined
   */
  href?: string;

  /**
   * Specify an icon to render at the end of the item.
   * Use the `icon` slot for full control over the rendered icon.
   * @default undefined
   */
  icon?: Icon;

  /**
   * Obtain a reference to the HTML element (anchor or button).
   * @default null
   */
  ref?: null | HTMLAnchorElement | HTMLButtonElement;

  children?: (this: void) => void;

  [key: `data-${string}`]: unknown;
};

export type ProfileMenuItemProps<Icon = any> = Omit<$RestProps, keyof $Props<Icon>> & $Props<Icon>;

export default class ProfileMenuItem<Icon = any> extends SvelteComponentTyped<
  ProfileMenuItemProps<Icon>,
  { click: WindowEventMap["click"] },
  {
    default: Record<string, never>;
    icon: Record<string, never>;
  }
> {}
