import { createApp } from 'vue'
import { createPinia } from 'pinia'
import App from './App.vue'
import { lang } from '@/i18n/lang'

export { lang }

// TypeScript declarations for global properties
declare module '@vue/runtime-core' {
  interface ComponentCustomProperties {
    $version: 'cn' | 'hk' | 'com'
  }
}

import '@icon-park/vue-next/styles/index.css'
import 'prosemirror-view/style/prosemirror.css'
import 'animate.css'
import '@/assets/styles/prosemirror.scss'
import '@/assets/styles/global.scss'
import '@/assets/styles/font.scss'

import Icon from '@/plugins/icon'
import Directive from '@/plugins/directive'

// 全局变量：判断当前版本 (cn/hk/com)
export const getCurrentVersion = () => {
  const href = window.location.href.toLowerCase()
  if (href.includes('cn')) return 'cn'
  if (href.includes('hk')) return 'hk'
  if (href.includes('com')) return 'com'
  return 'cn' // 默认cn版本
}

// 当前版本
export const currentVersion = getCurrentVersion()

export default {currentVersion, lang}

const app = createApp(App)
// 注册全局变量
app.config.globalProperties.$version = currentVersion

app.use(Icon)
app.use(Directive)
app.use(createPinia())
app.mount('#app')
