import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({

  history: createWebHistory(import.meta.env.BASE_URL),

   
  routes: [
    {
      path: '/',
      name: 'main',
      component:  () => import('@/views/Main.vue'),
      redirect: '/home',
      children: [
        {
          path: '/home',
          name: 'home',
          component: () => import('@/views/home/Index.vue')
        },
          {
          path: '/chat',
          name: 'chat',
          component: () => import('@/views/service/chat/Index.vue')
        },
        {
          path: '/order',
          name: 'order',
          component: () => import('@/views/order/Index.vue')
        },
        {
          path: '/start',
          name: 'start',
          component: () => import('@/views/start/Index.vue')
        },
        {
          path: '/service1',
          name: 'service',
          component: () =>  import('@/views/service/Index.vue')
        },
        {
          path: '/service',
          redirect: to => {
            if(localStorage.getItem("chatOpen")==="ok"){
              return 'chat'
            }
            return 'service1'
          },
        },
        {
          path: '/profile',
          name: 'profile',
          component: () => import('@/views/profile/Index.vue')
        }
      ]
    },
    {
      path: '/daily-check-in',
      name: 'dailyCheckIn',
      component: () => import('@/views/dailyCheckIn/Index.vue')
    },
    { 
      path: '/channel-select/:scenario',
      name: 'channelSelect',
      component: () => import('@/views/channelSelect/Index.vue')

    },
    {
      path: '/recharge/:configId',
      name: 'recharge',
      component: () => import('@/views/recharge/Index.vue')
    },
    {
      path: '/order-details/:orderId',
      name: 'orderDetails',
      component: () => import('@/views/payOrderDetails/Index.vue')
    },
    {
      path: '/withdrawal/:configId',
      name: 'withdrawal',
      component: () => import('@/views/withdrawal/Index.vue')
    },
    {
      path: '/bind-crypto/:configId',
      name: 'bindCrypto',
      component: () => import('@/views/bindCrypto/Index.vue')
    },
    {
      path: '/sign-in',
      name: 'signIn',
      component: () => import('@/views/signIn/Index.vue')
    },
    {
      path: '/sign-up',
      name: 'signUp',
      component: () => import('@/views/signUp/Index.vue')
    },
    {
      path: '/balance-record',
      name: 'balanceRecord',
      component: () => import('@/views/balanceRecord/Index.vue')
    },
    {
      path: '/settings',
      name: 'settings',
      component: () => import('@/views/settings/Index.vue')
    },
    {
      path: '/notification',
      name: 'notification',
      component: () => import('@/views/notification/Index.vue')
    },
    {
      path: '/invitation',
      name: 'invitation',
      component: () => import('@/views/invitation/Index.vue')
    },
    {
      path: '/help-guide',
      name: 'helpGuide',
      component: () => import('@/views/helpGuide/Index.vue')
    },
    {
      path: '/settings/personal',
      name: 'settingsInfo',
      component: () => import('@/views/settingsPersonal/Index.vue')
    },
    {
      path: '/settings/password',
      name: 'settingsPassword',
      component: () => import('@/views/password/Index.vue')
    },
    {
      path: '/settings/about',
      name: 'about',
      component: () => import('@/views/about/Index.vue')
    },
    {
      path: '/settings/language',
      name: 'language',
      component: () => import('@/views/language/Index.vue')
    },
    {
      path: '/wallet',
      name: 'wallet',
      component: () => import('@/views/wallet/Index.vue')
    },
    
  ]
})

export default router
