<script setup lang="ts">
import { zhCN, dateZhCN } from 'naive-ui';
import { omit } from 'naive-ui/es/_utils';
import { useAttrs } from 'vue';
import { storeToRefs } from 'pinia';
import { useLocalConfigStore } from '../../stores/useLocalConfigStore';

import { LayoutProvider } from '../layouts';

const { naiveThemeProps } = storeToRefs(useLocalConfigStore());

defineOptions({
  inheritAttrs: false,
});

const attrs = useAttrs();
</script>

<template>
  <n-config-provider
    v-bind="omit(attrs, ['locale', 'date-locale', 'theme-overrides'])"
    :locale="zhCN"
    :date-locale="dateZhCN"
    :theme-overrides="naiveThemeProps"
  >
    <n-dialog-provider>
      <n-message-provider>
        <n-notification-provider>
          <n-loading-bar-provider>
            <layout-provider>
              <slot />
            </layout-provider>
          </n-loading-bar-provider>
        </n-notification-provider>
      </n-message-provider>
    </n-dialog-provider>
  </n-config-provider>
</template>
