import { createApp } from 'vue'
import { createPinia } from 'pinia'
import ElementPlus, { ElDialog, ElDrawer } from 'element-plus'
import 'element-plus/dist/index.css'
import '@/styles/theme.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import App from './App.vue'
import router from './router'
import { i18n } from './i18n'

function disableOverlayClose(component: typeof ElDialog) {
  const props = component.props as Record<string, { default?: unknown }>
  if (props.closeOnClickModal) {
    props.closeOnClickModal.default = false
  }
}

disableOverlayClose(ElDialog)
disableOverlayClose(ElDrawer)

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}
app.use(createPinia())
app.use(i18n)
app.use(router)
app.use(ElementPlus)
app.mount('#app')
