from django.urls import path

from .agent_views import (
    VoiceAgentDetailView,
    VoiceAgentListCreateView,
    VoiceAgentOptionsView,
)
from .views import (
    CallHistoryView,
    CallReportView,
    CancelCallView,
    CandidateCallsView,
    RetryCallView,
    ScreeningDashboardView,
    ScreeningStatusView,
    StartScreeningView,
    TranscriptView,
    WebhookCompletedView,
    WebhookStatusView,
    WebhookTranscriptView,
)

urlpatterns = [
    path("", ScreeningStatusView.as_view(), name="ai-calls-status"),
    path("start/", StartScreeningView.as_view(), name="ai-calls-start"),
    path("dashboard/", ScreeningDashboardView.as_view(), name="ai-calls-dashboard"),
    # Call log for the Call History tab (additive, read-only).
    path("history/", CallHistoryView.as_view(), name="ai-calls-history"),
    # Voice Agents module (Hunar Agents API proxy). Declared before the
    # <int:call_id> routes so "agents" is never read as a call id. "options"
    # precedes <str:agent_id> for the same reason.
    path("agents/options/", VoiceAgentOptionsView.as_view(), name="voice-agents-options"),
    path("agents/", VoiceAgentListCreateView.as_view(), name="voice-agents"),
    path("agents/<str:agent_id>/", VoiceAgentDetailView.as_view(), name="voice-agent-detail"),

    # Candidate-scoped read (additive) — powers the Candidate Details call button.
    # Declared before the <int:call_id> routes so "candidate" is never read as an id.
    path("candidate/<int:candidate_id>/", CandidateCallsView.as_view(), name="ai-calls-candidate"),
    path("<int:call_id>/retry/", RetryCallView.as_view(), name="ai-call-retry"),
    path("<int:call_id>/cancel/", CancelCallView.as_view(), name="ai-call-cancel"),
    path("<int:call_id>/transcript/", TranscriptView.as_view(), name="ai-call-transcript"),
    path("<int:call_id>/report/", CallReportView.as_view(), name="ai-call-report"),

    # Platform callbacks (registered with and without a trailing slash — the
    # caller POSTs the exact configured URL and must never be redirected)
    path("webhook", WebhookStatusView.as_view()),
    path("webhook/", WebhookStatusView.as_view(), name="ai-calls-webhook"),
    path("transcript", WebhookTranscriptView.as_view()),
    path("transcript/", WebhookTranscriptView.as_view(), name="ai-calls-webhook-transcript"),
    path("completed", WebhookCompletedView.as_view()),
    path("completed/", WebhookCompletedView.as_view(), name="ai-calls-webhook-completed"),
]
