from __future__ import annotations

from typing import Any


class PipelineComponent:
    """Base interface for generated sklearn component adapters."""

    def __init__(self, **params: Any) -> None:
        self.params: dict[str, Any] = dict(params)
        self._fitted_model: Any = None

    def fit(self, X: Any, y: Any = None) -> "PipelineComponent":
        raise NotImplementedError()

    def transform(self, X: Any) -> Any:
        raise NotImplementedError()

    def fit_transform(self, X: Any, y: Any = None) -> Any:
        self.fit(X, y)
        return self.transform(X)

    def predict(self, X: Any) -> Any:
        raise NotImplementedError()

    def get_params(self) -> dict[str, Any]:
        return dict(self.params)

    def set_params(self, **params: Any) -> "PipelineComponent":
        self.params.update(params)
        return self

    def is_fitted(self) -> bool:
        return self._fitted_model is not None

    def to_dict(self) -> dict[str, Any]:
        return {"component": self.__class__.__name__, "params": dict(self.params)}

