from __future__ import annotations

from nees.types import EmotionResult, IntentResult, NEESRequest


class EmotionModulator:
    def modulate(self, request: NEESRequest, intent: IntentResult) -> EmotionResult:
        text = request.message.lower()
        cues: list[str] = []

        if any(word in text for word in ("panic", "hopeless", "urgent", "immediately")):
            cues.append("high_urgency_keyword")
            return EmotionResult(state="distressed", intensity=0.95, urgency="high", cues=cues)

        if any(word in text for word in ("sad", "lost", "confused", "stressed", "overwhelmed")):
            cues.append("stress_keyword")
            return EmotionResult(state="stressed", intensity=0.72, urgency="medium", cues=cues)

        if intent.label == "greeting":
            return EmotionResult(state="open", intensity=0.2, urgency="low", cues=["greeting"])

        if intent.label == "decision_support":
            return EmotionResult(state="focused", intensity=0.45, urgency="medium", cues=["decision"])

        return EmotionResult(state="neutral", intensity=0.3, urgency="low", cues=["default"])
