"""Factory functions for creating stage instances."""

from engine.pipeline.adapters.camera import CameraStage
from engine.pipeline.adapters.data_source import DataSourceStage
from engine.pipeline.adapters.display import DisplayStage
from engine.pipeline.adapters.effect_plugin import EffectPluginStage
from engine.pipeline.adapters.transform import FontStage


def create_stage_from_display(display, name: str = "terminal") -> DisplayStage:
    """Create a DisplayStage from a display instance."""
    return DisplayStage(display, name=name)


def create_stage_from_effect(effect_plugin, name: str) -> EffectPluginStage:
    """Create an EffectPluginStage from an effect plugin."""
    return EffectPluginStage(effect_plugin, name=name)


def create_stage_from_source(data_source, name: str = "headlines") -> DataSourceStage:
    """Create a DataSourceStage from a data source."""
    return DataSourceStage(data_source, name=name)


def create_stage_from_camera(camera, name: str = "vertical") -> CameraStage:
    """Create a CameraStage from a camera instance."""
    return CameraStage(camera, name=name)


def create_stage_from_font(
    font_path: str | None = None,
    font_size: int | None = None,
    font_ref: str | None = "default",
    name: str = "font",
) -> FontStage:
    """Create a FontStage with specified font configuration."""
    # FontStage currently doesn't use these parameters but keeps them for compatibility
    return FontStage(name=name)
