<script setup lang="ts">
import type { NavigationMenuRootEmits, NavigationMenuRootProps } from 'reka-ui';
import { NavigationMenuRoot, useForwardPropsEmits } from 'reka-ui';
import { cn } from '@/lib/utils';
import NavigationMenuViewport from './NavigationMenuViewport.vue';

defineOptions({ inheritAttrs: false });

const props = withDefaults(
  defineProps<
    NavigationMenuRootProps & {
      viewport?: boolean;
    }
  >(),
  {
    viewport: true,
  },
);
const emits = defineEmits<NavigationMenuRootEmits>();

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

<template>
  <NavigationMenuRoot
    v-slot="slotProps"
    data-slot="navigation-menu"
    :data-viewport="viewport"
    v-bind="{ ...forwarded, ...$attrs }"
    :class="
      cn(
        'group/navigation-menu relative flex max-w-max flex-1 items-center justify-center',
        $attrs.class ?? '',
      )
    "
  >
    <slot v-bind="slotProps" />
    <NavigationMenuViewport v-if="viewport" />
  </NavigationMenuRoot>
</template>
