"""Auto-generated by bindgen. Do not edit."""
# ruff: noqa: E501, F401, I001
# fmt: off

from __future__ import annotations

from dataclasses import dataclass
from typing import Any, Optional, Union

from wasmtime.component import Variant as _WitVariant
from wasmtime.component import VariantCase as _WitVariantCase

from .messages import Message


@dataclass(kw_only=True)
class TriggerParams:
    """Context passed to the trigger on each call."""
    trigger_id: str
    message_count: int
    last_message: Message | None


class TriggerError:
    """Why a trigger evaluation failed."""

    class Unknown(_WitVariantCase):
        """No trigger registered for the given id."""
        tag = 'unknown'

    class Failed(_WitVariantCase):
        """Trigger raised an exception."""
        tag = 'failed'

    _CASES: dict[str, type] = {
        'unknown': Unknown,
        'failed': Failed,
    }

    @staticmethod
    def lift(raw: _WitVariant) -> TriggerError:
        cls = TriggerError._CASES.get(raw.tag)
        if cls is None:
            raise ValueError(f'unknown TriggerError arm: {raw.tag!r}')
        return cls(raw.payload)
