import 'ant-design-vue/dist/antd.variable.less';
import '@crami/ui/dist/CramiUI.less';
import '@crami/bui/dist/CramiBui.less';

import CramiBui from '@crami/bui';
import CramiUI from '@crami/ui';

import bootstrap from '@crami/frame-lowcode/src/bootstrap';
import '@crami/frame-lowcode/src/standard-resource/index';

import '@surely-vue/table/dist/index.less';
import '@crami/icons/load';
import '@wangeditor/editor/dist/css/style.css';
import 'virtual:svg-icons-register';
import {
  SET_FIXED_HEADER,
  SET_FIXED_MULTI_TAB,
  SET_NAV_THEME,
} from '@/store/modules/app/mutations';

import {
  Layout,
  Menu,
  Row,
  Col,
  Card,
  Form,
  Dropdown,
  Select,
  Button,
  Checkbox,
  Tabs,
  Tag,
  Input,
  DatePicker,
  TimePicker,
  Radio,
  Tooltip,
  Space,
  Steps,
  Divider,
  Descriptions,
  Alert,
  Result,
  Statistic,
  Popconfirm,
  Popover,
  Table,
  Avatar,
  List,
  Progress,
  Switch,
  Modal,
  Rate,
  ConfigProvider,
  Empty,
  Spin,
  Drawer,
  PageHeader,
  Carousel,
  BackTop,
  Upload,
  Badge,
} from 'ant-design-vue';
import WujieVue from 'wujie-vue3';
import STable from '@surely-vue/table';
import { createApp } from 'vue';
import router from './router';
import store from './store';
import locale from './locales';
import App from './App.vue';

import { ProProvider, PageContainer, TransformVnode } from '@/components';
import { useIcons } from '@/icons';
import Authority from './utils/authority/authority.vue';
import './app.less';
import './router/router-guards';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
dayjs.extend(relativeTime);
const app = createApp(App);

import Preview from '@crami/frame-lowcode/src/views/preview/preview';
bootstrap({
  router,
});
// 导航守卫
import { createRouterGuard } from './guard';

app
  .use(router)
  .use(locale as any)
  .use(store)
  .use(STable)
  .use(Layout)
  .use(Menu)
  .use(Row)
  .use(Col)
  .use(Card)
  .use(Form)
  .use(Dropdown)
  .use(Select)
  .use(Button)
  .use(Checkbox)
  .use(Tabs)
  .use(Tag)
  .use(Input)
  .use(DatePicker)
  .use(TimePicker)
  .use(Radio)
  .use(Tooltip)
  .use(Space)
  .use(Steps)
  .use(Divider)
  .use(Descriptions)
  .use(Alert)
  .use(Result)
  .use(Statistic)
  .use(Popconfirm)
  .use(Popover)
  .use(Table)
  .use(Avatar)
  .use(List)
  .use(Progress)
  .use(Switch)
  .use(Modal)
  .use(Rate)
  .use(ConfigProvider)
  .use(Empty)
  .use(Spin)
  .use(Drawer)
  .use(PageHeader)
  .use(ProProvider)
  .use(Badge)
  .use(Carousel)
  .use(BackTop)
  .use(Upload)
  .use(ConfigProvider)
  .use(CramiUI)
  .use(CramiBui)
  .use(WujieVue)
  .component('editor-preview', Preview)
  .component(PageContainer.name, PageContainer)
  .component(TransformVnode.name, TransformVnode)
  .component(Authority.name, Authority);

useIcons(app);

// 添加路由守卫
createRouterGuard(router, app);

app.mount('#app');

// TODO:9.2独有，强制设置header和tab状态为fix
store.commit(`app/${SET_FIXED_HEADER}`, true);
store.commit(`app/${SET_FIXED_MULTI_TAB}`, true);
// 主题设置为白色
store.commit(`app/${SET_NAV_THEME}`, 'light');
