<script lang="ts">
  import { cn, type WithElementRef } from '$lib/utils/cn.svelte.js';
  import type { HTMLAttributes, Snippet } from 'svelte/elements';

  let {
    ref = $bindable(null),
    class: className,
    children,
    ...restProps
  }: WithElementRef<HTMLAttributes<HTMLButtonElement>> & { children?: Snippet } = $props();
</script>

<button
  bind:this={ref}
  data-slot="sidebar-menu-action"
  data-sidebar="menu-action"
  class={cn(
    'text-sidebar-foreground/70 ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground peer-hover/menu-button:text-sidebar-accent-foreground absolute top-1.5 right-1 flex aspect-square w-5 items-center justify-center rounded-md p-0 outline-none transition-transform focus-visible:ring-2 [&>svg]:size-4 [&>svg]:text-sidebar-accent-foreground',
    'peer-data-[size=sm]/menu-button:top-1 peer-data-[size=default]/menu-button:top-1.5 peer-data-[size=lg]/menu-button:top-2.5',
    'group-data-[collapsible=icon]:hidden',
    className
  )}
  {...restProps}
>
  {children}
</button>