//! Core routing types with no dependencies
//!
//! This module contains pure data types, static caches, and imports that are
//! shared across all routing modules. By centralizing these here, we prevent
//! circular dependencies.
//!
//! ARCHITECTURE PRINCIPLE: This module has NO re-exports from sibling modules.
//! It only imports from external crates and the parent `components` module.

use std::collections::HashMap;
use std::sync::OnceLock;

// Re-export core types from rustelo_core_types (external dependency - no circular risk)
pub use rustelo_core_types::{
    ComponentResult, ContentProvider, PageProvider, RouteResolver, RoutingResult,
};

// Import types from parent components module (safe - components doesn't import from routing)
pub use super::components::{RouteConfigToml, RoutesConfig};

// ============================================================================
// STATIC CACHES (Shared across all routing modules)
// ============================================================================

/// Cached routes loaded from TOML configuration
///
/// This cache stores the loaded routing configuration from TOML files or
/// embedded resources. It's initialized once on first access and remains valid
/// for the lifetime of the application.
pub static ROUTES_CACHE: OnceLock<RoutesConfig> = OnceLock::new();

/// Cache for route mappings to avoid rebuilding on every navigation
///
/// Structure: (forward_mappings, reverse_mappings)
/// - forward_mappings: default_lang_path → target_lang_path
/// - reverse_mappings: target_lang_path → default_lang_path
pub static ROUTE_MAPPINGS_CACHE: OnceLock<(HashMap<String, String>, HashMap<String, String>)> =
    OnceLock::new();

// ============================================================================
// HELPER TYPES
// ============================================================================

/// Route information structure
#[derive(Debug, Clone)]
pub struct RouteInfo {
    pub path: String,
    pub language: String,
    pub clean_path: String,
    pub is_default_language: bool,
}

/// Sitemap entry data
#[derive(Debug, Clone, PartialEq)]
pub struct SitemapEntry {
    pub url: String,
    pub language: String,
    pub alternate_urls: Vec<AlternateUrl>,
    pub last_modified: Option<String>,
    pub priority: f32,
}

/// Alternate URL for sitemap
#[derive(Debug, Clone, PartialEq)]
pub struct AlternateUrl {
    pub language: String,
    pub url: String,
}

/// Breadcrumb item structure
#[derive(Debug, Clone)]
pub struct BreadcrumbItem {
    pub title: String,
    pub url: String,
    pub is_current: bool,
}
