#!/usr/bin/env python3
"""
Version tracking for NICQS geometry files.

The geometry version follows the format: YEAR.MONTH.NR
- YEAR: Current year (e.g., 2026)
- MONTH: Current month (1-12)
- NR: Incremental number within the month (starts at 1)

Increment NR for changes within the same month.
The version automatically updates for new months/years.
"""

# Current geometry schema version
# Format: YEAR.MONTH.NR
# Increment NR when making changes to geometry structure in the same month
GEOMETRY_VERSION = "2026.1.2"

def check_geometry_version(loaded_version: str) -> tuple[bool, str]:
    """
    Check if loaded geometry version matches current version.

    Args:
        loaded_version: Version string from loaded geometry file

    Returns:
        tuple: (is_current, message)
            - is_current: True if versions match, False otherwise
            - message: Warning message if versions don't match, empty string if they do
    """
    if loaded_version == GEOMETRY_VERSION:
        return True, ""

    warning_msg = (
        f"\n{'='*70}\n"
        f"WARNING: Geometry version mismatch!\n"
        f"{'='*70}\n"
        f"  Loaded geometry version:  {loaded_version}\n"
        f"  Current geometry version: {GEOMETRY_VERSION}\n"
        f"\n"
        f"  The geometry file was created with an older version of the\n"
        f"  geometry creator. This may cause errors or incorrect results.\n"
        f"\n"
        f"  RECOMMENDED ACTION:\n"
        f"  Please regenerate the geometry using nicqs/geometry.py with\n"
        f"  the current version of the code.\n"
        f"{'='*70}\n"
    )

    return False, warning_msg
