"""
Per-engine capability metadata: which engines support raster studies.

Engine bridges (NetWeaver / CDP / Portfolio) are intentionally
GIS-agnostic — they live in `python-bridge/` and know nothing about
QgsRasterLayer or LayerKind. So the "does this engine handle a
raster study area?" answer lives here, on the QGIS-plugin side,
keyed on EngineType.

Used by:
  - dock_widget._assessment_supports_current_engines: gates the
    Create-Analysis flows so a raster study area only offers engines
    that can consume a raster RAT.
  - Future raster-aware analysis dialogs: filter the engine picker
    by `supports_raster_study(engine_type)`.

Today all engines are False (raster engines arrive when the raster
analysis dialogs ship). Flip an engine to True in the registry once
its bridge knows how to take a RasterStudyInput.
"""

from __future__ import annotations

from .models import EngineType


# Single source of truth for raster-study capability. Add an engine
# here when its bridge gains raster support; the rest of the codebase
# reads through `supports_raster_study()` and stays unchanged.
_SUPPORTS_RASTER_STUDY: dict = {
    EngineType.NETWEAVER: False,
    EngineType.CDP: False,
    EngineType.TEMPLATE_2: False,  # Portfolio
    EngineType.TEMPLATE_1: False,  # LPA
    EngineType.WORKFLOW: False,
    EngineType.PYTHON_SCRIPT: False,
}


def supports_raster_study(engine_type: EngineType) -> bool:
    """Return True if this engine can consume a raster study's RAT.

    Defaults to False for unknown engines so the gate fails closed.
    """
    return _SUPPORTS_RASTER_STUDY.get(engine_type, False)


def supports_vector_study(engine_type: EngineType) -> bool:
    """Symmetric helper. All current engines support vector studies.

    Kept as a function (not a constant) so future GIS-only engines
    that don't make sense for vector input (e.g. a raster-algebra
    workflow) have a place to opt out without churn elsewhere.
    """
    # Today every engine is vector-capable. Flip individual entries
    # in a future _SUPPORTS_VECTOR_STUDY dict if that changes.
    return True


def any_engine_supports_raster_study() -> bool:
    """Convenience for UI gating: are there ANY raster-capable engines?

    The raster Create-Study-Area dialog uses this to decide whether
    to even offer "open an analysis on this study". Until at least
    one engine flips to True, raster studies stop at the overlay
    output and can only be displayed / inspected.
    """
    return any(_SUPPORTS_RASTER_STUDY.values())
