from __future__ import annotations

from dataclasses import dataclass
from typing import Optional

from analogai.deepthink.application.value_objects.user_agent import UserAgent


@dataclass(frozen=True)
class UserAgentResolver:
    default_user_id: str
    default_agent_id: str
    default_authority: float = 1.0

    def resolve_user_agent(self, user_agent: Optional[UserAgent]) -> UserAgent:
        if user_agent is not None:
            return user_agent
        return UserAgent(
            user_id=self.default_user_id,
            agent_id=self.default_agent_id,
            user_authority=self.default_authority,
        )
