"""FilterInstance data model for serializable filter configurations."""

from dataclasses import dataclass, field
from typing import Any, Dict


@dataclass
class FilterInstance:
    """A configured instance of a filter within a postprocessing template."""

    filter_id: str
    options: Dict[str, Any] = field(default_factory=dict)

    def to_dict(self) -> dict:
        return {
            "filter_id": self.filter_id,
            "options": dict(self.options),
        }

    @classmethod
    def from_dict(cls, data: dict) -> "FilterInstance":
        return cls(
            filter_id=data["filter_id"],
            options=data.get("options", {}),
        )
