import ArcoVue from '@arco-design/web-vue';
import ArcoVueIcon from '@arco-design/web-vue/es/icon';
import { createApp } from 'vue';
import globalComponents from '@/components';
import '@/assets/style/global.less';
import { setupHttp } from '@/plugins/http';
import directive from '@/directive';
import i18n from '@/locale';
import router from '@/router';
import store from '@/store';
import setupErrorReport from '@/utils/error-report';
import App from './App.vue';

async function bootstrap() {
  if (import.meta.env.DEV) {
    await import('@/mocks');
  }

  const app = createApp(App);

  app.use(ArcoVue, {});
  app.use(ArcoVueIcon);
  app.use(router);
  app.use(store);
  app.use(i18n);
  app.use(globalComponents);
  app.use(directive);

  setupHttp();
  setupErrorReport(
    app,
    import.meta.env.VITE_ERROR_REPORT_URL?.trim() ?? '',
  );

  app.mount('#app');
}

bootstrap();
