1<script lang="ts">
 2	import { cn, type WithElementRef } from '$lib/components/ui/utils.js';
 3	import type { Snippet } from 'svelte';
 4	import type { HTMLAnchorAttributes } from 'svelte/elements';
 5
 6	let {
 7		ref = $bindable(null),
 8		children,
 9		child,
10		class: className,
11		size = 'md',
12		isActive = false,
13		...restProps
14	}: WithElementRef<HTMLAnchorAttributes> & {
15		child?: Snippet<[{ props: Record<string, unknown> }]>;
16		size?: 'sm' | 'md';
17		isActive?: boolean;
18	} = $props();
19
20	const mergedProps = $derived({
21		class: cn(
22			'text-sidebar-foreground ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground active:bg-sidebar-accent active:text-sidebar-accent-foreground [&>svg]:text-sidebar-accent-foreground outline-hidden flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0',
23			'data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground',
24			size === 'sm' && 'text-xs',
25			size === 'md' && 'text-sm',
26			'group-data-[collapsible=icon]:hidden',
27			className
28		),
29		'data-slot': 'sidebar-menu-sub-button',
30		'data-sidebar': 'menu-sub-button',
31		'data-size': size,
32		'data-active': isActive,
33		...restProps
34	});
35</script>
36
37{#if child}
38	{@render child({ props: mergedProps })}
39{:else}
40	<a bind:this={ref} {...mergedProps}>
41		{@render children?.()}
42	</a>
43{/if}