import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { LandingPageComponent } from './landing-page/landing-page.component';
import { CesiumMapComponent } from './cesium-map/cesium-map.component';
import { SigninComponent } from './signin/signin.component';
import { SignupComponent } from './signup/signup.component';
import { MapSettingsComponent } from './map-settings/map-settings.component';
import { EmbedCesiumComponent } from './embed-cesium/embed-cesium.component';
import { EmbedCesiumNoLoaderComponent } from './embed-cesium-no-loader/embed-cesium-no-loader.component';
import { EmbedCesiumTransparentComponent } from './embed-cesium-transparent/embed-cesium-transparent.component';
import { MapWrapperComponent } from './map-wrapper/map-wrapper.component';


const childRoutes: Routes = [
  { path: '', component: LandingPageComponent },
  { path: 'cesium', component: CesiumMapComponent },
  { path: 'signin', component: SigninComponent },
  { path: 'signup', component: SignupComponent },
  { path: 'map-settings', component: MapSettingsComponent },
  { path: 'embed-cesium', component: EmbedCesiumComponent },
  { path: 'embed-cesium-no-loader', component: EmbedCesiumNoLoaderComponent },
  { path: 'embed-cesium-transparent', component: EmbedCesiumTransparentComponent },
  { path: 'map-wrapper', component: MapWrapperComponent },
  { path: '**', redirectTo: '' }
];

const routes: Routes = [
  // Redirect bare root to default language (en)
  { path: '', redirectTo: 'en', pathMatch: 'full' },
  // Allow direct access to map-settings (no language prefix)
  { path: 'map-settings', component: MapSettingsComponent },
  // Support suffix-language style: /embed-cesium/ar
  // Plain embed route (no language) — e.g. /embed-cesium
  { path: 'embed-cesium', component: EmbedCesiumComponent },
  { path: 'embed-cesium-no-loader', component: EmbedCesiumNoLoaderComponent },
  { path: 'embed-cesium-transparent', component: EmbedCesiumTransparentComponent },
  { path: 'map-wrapper', component: MapWrapperComponent },
  // Support suffix-language style: /embed-cesium/ar
  { path: 'embed-cesium/:lang', component: EmbedCesiumComponent },
  { path: 'embed-cesium-no-loader/:lang', component: EmbedCesiumNoLoaderComponent },
  { path: 'embed-cesium-transparent/:lang', component: EmbedCesiumTransparentComponent },
  { path: 'map-wrapper/:lang', component: MapWrapperComponent },
  // Language prefixed routes, e.g. /fr, /ar, /en
  { path: ':lang', children: childRoutes },
  // Fallback
  { path: '**', redirectTo: '' }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
