"""Audio Filter Template meta-filter -- references another audio processing template.

This filter exists in the registry for UI discovery only.  It is never
instantiated at runtime: the audio processing pipeline expands it into the
referenced template's filters when building the filter chain.
"""

from typing import List

from wled_controller.core.audio.analysis import AudioAnalysis
from wled_controller.core.audio.filters.base import AudioFilter, AudioFilterOptionDef
from wled_controller.core.audio.filters.registry import AudioFilterRegistry


@AudioFilterRegistry.register
class AudioFilterTemplateFilter(AudioFilter):
    """Include another audio filter template's chain at this position."""

    filter_id = "audio_filter_template"
    filter_name = "Audio Filter Template"

    @classmethod
    def get_options_schema(cls) -> List[AudioFilterOptionDef]:
        return [
            AudioFilterOptionDef(
                key="template_id",
                label="Template",
                option_type="select",
                default="",
                min_value=None,
                max_value=None,
                step=None,
                choices=[],  # populated dynamically by GET /api/v1/audio-filters
            ),
        ]

    def process(self, analysis: AudioAnalysis) -> AudioAnalysis:
        # Never called -- expanded at pipeline build time.
        return analysis
