"""
Abstract Syntax Tree (AST) nodes for the time expression parser.
"""

from abc import ABC, abstractmethod
from typing import Optional, List
from dataclasses import dataclass
import datetime


@dataclass
class ASTNode(ABC):
    """Base class for all AST nodes."""
    pass


@dataclass
class NumberNode(ASTNode):
    """Represents a numeric value."""
    value: int


@dataclass
class DateNode(ASTNode):
    """Represents a date specification."""
    year: Optional[ASTNode]
    month: Optional[ASTNode]
    day: Optional[ASTNode]


@dataclass
class TimeNode(ASTNode):
    """Represents a time specification."""
    hour: Optional[ASTNode]
    minute: Optional[ASTNode]
    second: Optional[ASTNode]
    is_24hour: bool = False
    period: Optional[str] = None  # AM or PM


@dataclass
class RelativeDateNode(ASTNode):
    """Represents a relative date specification."""
    years: int = 0
    months: int = 0
    weeks: int = 0
    days: int = 0


@dataclass
class RelativeTimeNode(ASTNode):
    """Represents a relative time specification."""
    hours: float = 0.0
    minutes: float = 0.0
    seconds: float = 0.0


@dataclass
class WeekdayNode(ASTNode):
    """Represents a weekday specification."""
    weekday: int  # 0=Monday, 6=Sunday
    scope: str  # current, last, next


@dataclass
class TimeExpressionNode(ASTNode):
    """Represents a complete time expression."""
    date: Optional[DateNode] = None
    time: Optional[TimeNode] = None
    relative_date: Optional[RelativeDateNode] = None
    relative_time: Optional[RelativeTimeNode] = None
    weekday: Optional[WeekdayNode] = None