from __future__ import annotations

from typing import Iterable, List

from analogai.deepthink.application.usecases.learning.make_conditional_statement.models import CriterionValue


class AttributeValueNormalizer:
    def normalize(self, attributes: Iterable) -> List[CriterionValue]:
        if not attributes:
            return []
        normalized: List[CriterionValue] = []
        for attr in attributes:
            tag = attr.tag
            values = attr.values or []
            value = values[0] if values else None
            unit = attr.unit
            min_value = attr.min_value
            max_value = attr.max_value
            if tag:
                normalized.append(
                    CriterionValue(
                        tag=tag,
                        value=value,
                        unit=unit,
                        min_value=min_value,
                        max_value=max_value,
                    )
                )
        return normalized
