from dataclasses import dataclass

from .redact_option import RedactOption, normalize_redact_option, is_redact_option_falsy
from .._core import redact_dictionary as core_redact_dictionary


@dataclass
class RedactedDictionary:
    value: dict
    redacted_paths: list[str]


@dataclass
class RedactedSerializedObject:
    value: str | None
    redacted_paths: list[str]


def redact_dictionary(
    dictionary: dict, redact: RedactOption | None
) -> RedactedDictionary:
    normalized_redact_option = normalize_redact_option(redact)
    if is_redact_option_falsy(normalized_redact_option):
        return RedactedDictionary(value=dictionary, redacted_paths=[])

    result, redacted_paths = core_redact_dictionary(
        dictionary, normalized_redact_option
    )
    return RedactedDictionary(value=result, redacted_paths=redacted_paths)
