import { createRouter, createWebHistory, type RouteRecordRaw, } from 'vue-router'; import AppLayout from '@/appLayout.vue'; import HomePage from '@/pages/Home.vue'; import NotFound from '@/pages/NotFound.vue'; // The route-merger composes feature routes into this `routes` array by matching // on `path`, so features ship a router.ts with the same top-level `path: ''` // node and their child routes are appended as siblings of the base app's routes. export const routes: RouteRecordRaw[] = [ { path: '/', component: AppLayout, children: [ { path: '', component: HomePage, meta: { showInNavigation: true, label: 'Home' }, }, { path: ':pathMatch(.*)*', component: NotFound, }, ], }, ]; // Normalize basename: strip trailing slash so it matches URLs like /lwr/application/ai/c-app const rawBasePath = (globalThis as { SFDC_ENV?: { basePath?: string } }) .SFDC_ENV?.basePath; const basename = typeof rawBasePath === 'string' ? rawBasePath.replace(/\/+$/, '') : undefined; export const router = createRouter({ history: createWebHistory(basename), routes, });