from typing import Any, List, Optional, Union

from ..report_conditions import CustomReportConditions
from ..report_element import CustomReportElement
from ..report_named_resource import CustomReportNamedResource


class AddBoldStylePreparer(CustomReportElement):
    """Applies bold style to specified fields based on a resource condition."""

    def __init__(
        self,
        fields: List[str],
        resource: Union[CustomReportNamedResource, Any],
        bold_field: Optional[str] = None,
        conditions: Optional[List[CustomReportConditions]] = None,
    ):
        """Creates an AddBoldStylePreparer.

        Args:
            fields: Fields to apply bold style to.
            resource: Resource that determines which rows receive bold style.
            bold_field: Optional specific field that drives the bold condition.
            conditions: Export-format conditions that control when this preparer is applied.
        """
        super().__init__(name="add_bold_style", conditions=conditions)
        self.add_param("fields", fields)
        self.add_param("resource", resource)
        self.add_param("bold_field", bold_field)
