"""
Base class for field normalizers.
"""

from abc import ABC, abstractmethod
from shared.utils.text_cleaner import TextCleaner


class BaseNormalizer(ABC):
    """Base class for all field normalizers."""

    @staticmethod
    def clean_text(text: str) -> str:
        """Clean text using shared TextCleaner."""
        return TextCleaner.clean_text(text)

    @abstractmethod
    def normalize(self, value: str) -> list[str]:
        """
        Normalize a field value and return all variants.

        Args:
            value: Raw field value

        Returns:
            List of normalized variants for matching
        """
        pass

    def __call__(self, value: str) -> list[str]:
        """Allow normalizer to be called as a function."""
        if value is None or (isinstance(value, str) and not value.strip()):
            return []
        return self.normalize(str(value))
