"""
{{ name | pascal_case }} Middleware.
This is automatically generated by FletX CLI.
Customize this middleware as needed.
"""

from typing import Optional

from fletx.navigation import RouteMiddleware, RouteInfo, NavigationIntent # type: ignore
from fletx.utils import get_logger # type: ignore


class {{ name | pascal_case }}Middleware(RouteMiddleware):
    """{{ name | pascal_case }} Middleware."""
    
    def __init__(self):
        self.logger = get_logger('FletX.{{ name | pascal_case }}Middleware')
    
    async def before_navigation(
        self, 
        from_route: RouteInfo, 
        to_route: RouteInfo
    ) -> Optional[NavigationIntent]:
        """Called before navigation."""

        pass
    
    async def after_navigation(self, route_info: RouteInfo) -> None:
        """Called after navigation."""

        pass

    async def on_navigation_error(
        self, 
        error: Exception, 
        route_info: RouteInfo
    ) -> None:
        """Execute when navigation fails."""
        self.logger.error(f"Navigation error: {error}")
        pass
        