from __future__ import annotations
from typing import Protocol
from customtkinter import (
    CTkFrame, CTk, CTkButton, 
    CTkEntry, CTkLabel, CTkScrollableFrame,
    CTkOptionMenu, CTkProgressBar)
import pandas as pd
import logging

# --------------------------
# Class Instances Signatures
# --------------------------

# ./main.py
class ApplicationSignature(Protocol):
    """Protocol for the main.py Application class."""
    def __init__(self): ...
    # For Validator
    def start_validator(self) -> None: 
        """Start the validation app."""
        ...
    def close_validator(self) -> None: 
        """Close the validation app."""
        ...
    # For Updater
    def start_updater(self) -> None:
        """Start the update app."""
        ...
    def close_updater(self) -> None:
        """Close the update app."""
        ...
    # Functionality
    def update_requested(self, kit_version: str) -> None:
        """Request update to a specific validation kit version.

        Args:
            kit_version (str): The kit version to update to.
        """
        ...
    def update_done(self) -> None:
        """Signal that the update is done and restart the validator."""
        ...

# ./validator/validator.py
class ValidatorAppSignature(Protocol):
    def __init__(self): ...
    def start_window(self):
        """Start the validator window."""
        ...
    def close_window(self):
        """Close the validator window"""
        ...
        
# ./validator/src/ui/validator_window.py
class ValidatorWindowSignature(CTk):
    """Protocol for that validator window"""
    def __init__(self):
        ...
    def setup_window(self):
        """Set the window properties and icon."""
        ...
    def create_login_view(self):
        """Create the login view and controller."""
        ...
    def create_validator_view(self):
        """Create the validator view and controller"""
        ...
    def show_login_view(self):
        """Show the login view."""
        ...
    def show_validator_view(self):
        """Show the validator view"""
        ...
    def delete_login_view(self):
        """Delete login view and controller instances."""
        ...
    def delete_validator_view(self):
        """Delete controller view and controller instances."""
        ...

# ./validator/src/ui/login_view.py
class ValidatorLoginViewSignature(CTkFrame):
    template: dict[str, str]
    
    authLoginButton: CTkButton
    authEmailEntry: CTkEntry
    authPasswordEntry: CTkEntry
    authWarningLabel: CTkLabel
    
    def __init__(self, master, width = 200, height = 200, 
            corner_radius = None, border_width = None, 
            bg_color = "transparent", fg_color = None, 
            border_color = None, background_corner_colors = None, 
            overwrite_preferred_drawing_method = None, **kwargs):
        super().__init__(master, width, height, 
            corner_radius, border_width, bg_color, 
            fg_color, border_color, background_corner_colors, 
            overwrite_preferred_drawing_method, **kwargs)
        
    def setup_view(self):
        """Create the widgets, set template and window title"""
        ...
    def template_processing(self, template: dict[str, str]) -> dict[str, str]:
        """Process template to fix certain aspects"""
        ...

# Progressbar
class GetProgressbarSteps(Protocol):
    def __call__(self, steps: int) -> None: ...
class GetProgressbarUpdate(Protocol):
    def __call__(self) -> None: ...
class GetProgressbarEnd(Protocol):
    def __call__(self, validation_status: bool) -> None: ...

# ./validator/src/ui/validator_view.py
class ValidatorValidatorViewSignature(CTkFrame):
    template: dict[str, str]
    images: dict[str, str]
    
    kitVersion: str
    
    # Labels
    sidenavbarTitleLabel: CTkLabel
    footerVersionLabel: CTkLabel
    # Buttons
    sidenavbarLogoutButton: CTkButton
    sidenavbarValidationTabButton: CTkButton
    sidenavbarRaportTabButton: CTkButton
    sidenavbarNewsTabButton: CTkButton
    sidenavbarPackagesTabButton: CTkButton
    sidenavbarKitsTabButton: CTkButton
    validationTabChooseButton: CTkButton
    validationTabVerifyButtonVerify: CTkButton
    validationTabVerifyButtonUpdate: CTkButton
    validationTabValidateButton: CTkButton
    validationTabSaveRaportButton: CTkButton
    sidenavbarTesterButton: CTkButton
    sidenavbarSupportButton: CTkButton
    # Entry
    validationTabChooseEntry: CTkEntry
    validationTabSaveRaportEntry: CTkEntry
    # Frames
    RaportTabMainFrame: CTkFrame
    NewsTabMainFrame: CTkFrame
    PackagesTabMainFrame: CTkFrame
    KitsTabMainFrame: CTkFrame
    NewsKitsTabMainFrame: CTkFrame
    ValidationTabMainFrame: CTkFrame
    RaportTabScrollframe: CTkFrame
    PackagesTabScrollframe: CTkFrame
    KitsTabScrollframe: CTkFrame
    NewsTabScrollframe: CTkFrame
    footerFrame: CTkFrame
    # Scrollframes
    validationTabVerifyScrollFrame: CTkScrollableFrame
    validationTabValidateScrollFrame: CTkScrollableFrame
    # OptionMeny
    validationTabValidateOptionMenu: CTkOptionMenu
    # Progressbar
    validationTabProgressBar: CTkProgressBar
    
    def __init__(self, master, width = 200, height = 200, 
            corner_radius = None, border_width = None, 
            bg_color = "transparent", fg_color = None, 
            border_color = None, background_corner_colors = None, 
            overwrite_preferred_drawing_method = None, **kwargs):
        super().__init__(master, width, height, 
            corner_radius, border_width, bg_color, 
            fg_color, border_color, background_corner_colors, 
            overwrite_preferred_drawing_method, **kwargs)
    def setup_view(self):
        """Create the widgets, set template and window title"""
        ...
    def template_processing(self, template: dict[str, str]) -> dict[str, str]:
        """Process template to fix certain aspects"""
        ...
    def create_validation_tab(self):
        """Create the validation tab."""
        ...
    def create_raports_tab(self):
        """Create the raports tab."""
        ...
    def create_news_tab(self):
        """Create the news tab."""
        ...
    def create_packages_tab(self):
        """Create the packages tab."""
        ...
    def create_kits_tab(self):
        """Create the kits tab."""
        ...
    def place_tester_button(self, command) -> None:
        """If the user is a tester it places this button."""
        ...
        
# For Validation Packages
class ValidationSignature(Protocol):
    def __init__(self, logger: logging.Logger): ...
    def validate(self, file_path: str, verification_results: dict[str, str],
            get_validation_results_callback: GetValidationResultsCallback,
            template_url: str, zip_struct_rules_get: ZipStructRulesGet, 
            gpkg_struct_rules_get: GpkgStructRulesGet, gpkg_data_rules_get: GpkgDataRulesGet,
            uat_limit_get: UatLimitGet, progressbar_steps: GetProgressbarSteps, 
            progressbar_update: GetProgressbarUpdate, progressbar_end: GetProgressbarEnd): ...
# --------------------------
# --------------------------

# ----------------------------
# Callback Function Signatures
# ----------------------------

class GetVerificationResultsCallback(Protocol):
    def __call__(self, complete: bool = None, message: str = None, verification_result: dict[str, str] = None) -> None: ... 
class GetValidationResultsCallback(Protocol):
    def __call__(self, complete: bool = None, status_validation: bool = None, message: str = None, raport: pd.DataFrame = None) -> None: ...
class ZipStructRulesGet(Protocol):
    def __call__(self) -> dict[str, str] | str: ...
class GpkgStructRulesGet(Protocol):
    def __call__(self) -> dict[str, str] | str: ...
class GpkgDataRulesGet(Protocol):
    def __call__(self) -> dict[str, str] | str: ...
class UatLimitGet(Protocol):
    def __call__(self, siruta: str) -> dict[str, str] | str: ...
class RequestUpdateCallback(Protocol):
    def __call__(self, kit_url: str) -> None: ...
# ----------------------------
# ----------------------------

# -------------------------------------------------
# Updater Classes and Callback Functions Signatures
# -------------------------------------------------
class UpdateDoneCallback(Protocol):
    def __call__(self) -> None: ...

class AfterUpdateCallback(Protocol):
    def __call__(self) -> None: ...

class AfterUpdateFailCallback(Protocol):
    def __call__(self) -> None: ...

class UpdaterWindowSignature(CTk):
    def __init__(self): ...
    def setup_window(self): ...
    def create_update_view(self): ...
    def show_update_view(self): ...
    def delete_update_view(self): ...

class UpdaterViewSignature(CTkFrame):
    # Label
    updateLabelMain: CTkLabel
    # Progressbar
    updateProgressBar: CTkProgressBar
    # Template
    template: dict[str:str]
    
    def __init__(self, master, width = 200, height = 200, 
            corner_radius = None, border_width = None, 
            bg_color = "transparent", fg_color = None, 
            border_color = None, background_corner_colors = None, 
            overwrite_preferred_drawing_method = None, **kwargs):
        super().__init__(master, width, height, 
            corner_radius, border_width, bg_color, 
            fg_color, border_color, background_corner_colors, 
            overwrite_preferred_drawing_method, **kwargs)
# -------------------------------------------------
# -------------------------------------------------