import { createWebHistory, createWebHashHistory, createMemoryHistory, createRouter } from "vue-router";
// lazy-loaded
const Home = () => import("./components/Home.vue")

const P_NewtonCourse = () => import("./components/jinro/P_NewtonCourse.vue")
const P_JinroHighSchool_2023 = () => import("./components/jinro/P_JinroHighSchool_2023.vue")
const P_JinroSchool = () => import("./components/jinro/P_JinroSchool.vue")
const P_Bigdata_JinroSchool = () => import("./components/jinro/P_Bigdata_JinroSchool.vue")

const EntryKingBasic = () => import("./components/services/EntryKingBasic.vue")
const EntryBasic = () => import("./components/services/EntryBasic.vue")
const EntryGame = () => import("./components/services/EntryGame.vue")
const AppInventor = () => import("./components/services/AppInventor.vue")
const EntryDog = () => import("./components/services/EntryDog.vue")
const EntryHigh = () => import("./components/services/EntryHigh.vue")

const HamsterBot = () => import("./components/services/HamsterBot.vue")
const AsomBot = () => import("./components/services/AsomBot.vue")
const HaloCode = () => import("./components/services/HaloCode.vue")

const TinkerRoom = () => import("./components/services/TinkerRoom.vue")
const TinkerObject = () => import("./components/services/TinkerObject.vue")
const TinkerSimLab = () => import("./components/services/TinkerSimLab.vue")

const VibeFoodElemental = () => import("./components/services/VibeFoodElemental.vue")
const VibeGameElemental = () => import("./components/services/VibeGameElemental.vue")
const VibeStartupMiddle = () => import("./components/services/VibeStartupMiddle.vue")
const VibeStartupHigh = () => import("./components/services/VibeStartupHigh.vue")

const AchitectureElemental = () => import("./components/services/AchitectureElemental.vue")

const HtmlBasic = () => import("./components/services/HtmlBasic.vue")
const JavaScriptBasic = () => import("./components/services/JavaScriptBasic.vue")

const JapanessBasic = () => import("./components/services/JapanessBasic.vue")
const JapanessMedium = () => import("./components/services/JapanessMedium.vue")
const JapanessDailyBasic = () => import("./components/services/JapanessDailyBasic.vue")

const HanjaBasic = () => import("./components/services/HanjaBasic.vue")
const HanjaMidium = () => import("./components/services/HanjaMidium.vue")


const routes = [
  {
    path: "/",
    name: 'home',
    component: Home,
  },

  {
    path: "/newton",
    component: P_NewtonCourse,
  },
  {
    path: "/jinro_2023",
    component: P_JinroHighSchool_2023,
  },
  {
    path: "/jinro",
    component: P_JinroSchool,
  },
  {
    path: "/bigdata_jinro",
    component: P_Bigdata_JinroSchool,
  },

  {
    path: "/entry_k",
    component: EntryKingBasic,
  },
  {
    path: "/entry_b",
    component: EntryBasic,
  },
  {
    path: "/entry_g",
    component: EntryGame,
  },
  {
    path: "/entry_h",
    component: EntryHigh,
  },
  {
    path: "/inventor",
    component: AppInventor,
  },
  {
    path: "/entry_dog",
    component: EntryDog,
  },
  {
    path: "/hBot",
    component: HamsterBot,
  },
  {
    path: "/aBot",
    component: AsomBot,
  },
  {
    path: "/hCode",
    component: HaloCode,
  },

  {
    path: "/tinker_r",
    component: TinkerRoom,
  },
  {
    path: "/tinker_o",
    component: TinkerObject,
  },
  {
    path: "/tinker_s",
    component: TinkerSimLab,
  },

  {
    path: "/html_b",
    component: HtmlBasic,
  },
  {
    path: "/script_b",
    component: JavaScriptBasic,
  },
  
  {
    path: "/jp_b",
    component: JapanessBasic,
  },
  {
    path: "/jp_m",
    component: JapanessMedium,
  },
  {
    path: "/jp_daily_b",
    component: JapanessDailyBasic,
  },

  {
    path: "/hj_b",
    component: HanjaBasic,
  },
  {
    path: "/hj_m",
    component: HanjaMidium,
  },

  {
    path: "/vibe_e",
    component: VibeFoodElemental,
  },
  {
    path: "/vibe_g",
    component: VibeGameElemental,
  },
  {
    path: "/vibe_m",
    component: VibeStartupMiddle,
  },
  {
    path: "/vibe_h",
    component: VibeStartupHigh,
  },

  {
    path: "/achi_e",
    component: AchitectureElemental,  
  },  

];
// const scrollBehavior = function (to, from, savedPosition) {
//   if (to.hash) {
//     return {
//       selector: to.hash,
//       offset: { x: 0, y: -500 }
//     }
//   }
//   return { x: 0, y: 0 };
// }

// const router = new VueRouter({
//   mode: "history",
//   routes,
// });

const router = createRouter({
  // history: createWebHistory(process.env.BASE_URL),
  // history: createWebHashHistory(),
  history: createWebHistory(),
  // history: createMemoryHistory(),
  // scrollBehavior,
  routes,
});

// router.beforeEach((to, from, next) => {
//   const publicPages = ['/login', '/register', '/home'];
//   const authRequired = !publicPages.includes(to.path);
//   const loggedIn = localStorage.getItem('user');

//   // trying to access a restricted page + not logged in
//   // redirect to login page
//   if (authRequired && !loggedIn) {
//     next('/login');
//   } else {
//     next();
//   }
// });

export default router;