<script setup lang="ts">
import type { ListboxItemEmits, ListboxItemProps } from 'reka-ui';
import type { HTMLAttributes } from 'vue';
import { ListboxItem, useForwardPropsEmits } from 'reka-ui';
import { computed } from 'vue';
import { cn, omitClass } from '@/lib/utils';

const props = defineProps<
  ListboxItemProps & { class?: HTMLAttributes['class'] }
>();
const emits = defineEmits<ListboxItemEmits>();

const delegatedProps = computed(() => omitClass(props));

const forwarded = useForwardPropsEmits(delegatedProps, emits);
</script>

<template>
  <ListboxItem
    data-slot="listbox-item"
    :class="
      cn(
        'hover-layer hover-layer-default data-[highlighted]:text-foreground [&_svg:not([class*=\'text-\'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*=\'size-\'])]:size-4',
        props.class,
      )
    "
    v-bind="forwarded"
  >
    <slot />
  </ListboxItem>
</template>
