"""
URL configuration for user account management API endpoints.
"""

from django.urls import include, path
from rest_framework.routers import DefaultRouter

from . import views, views_credits, views_magic_link

# Register ViewSets
router = DefaultRouter()
router.register(r"credits", views_credits.RideCreditViewSet, basename="ride-credit")

urlpatterns = [
    # Admin endpoints for user management
    path(
        "users/<str:user_id>/delete/",
        views.delete_user_preserve_submissions,
        name="delete_user_preserve_submissions",
    ),
    path(
        "users/<str:user_id>/deletion-check/",
        views.check_user_deletion_eligibility,
        name="check_user_deletion_eligibility",
    ),
    # Self-service account deletion endpoints
    path(
        "delete-account/request/",
        views.request_account_deletion,
        name="request_account_deletion",
    ),
    path(
        "delete-account/verify/",
        views.verify_account_deletion,
        name="verify_account_deletion",
    ),
    path(
        "delete-account/cancel/",
        views.cancel_account_deletion,
        name="cancel_account_deletion",
    ),
    # Data Export endpoint
    path("data-export/", views.export_user_data, name="export_user_data"),
    # User profile endpoints
    path("profile/", views.get_user_profile, name="get_user_profile"),
    path("profile/account/", views.update_user_account, name="update_user_account"),
    path("profile/update/", views.update_user_profile, name="update_user_profile"),
    # User preferences endpoints
    path("preferences/", views.get_user_preferences, name="get_user_preferences"),
    path(
        "preferences/update/",
        views.update_user_preferences,
        name="update_user_preferences",
    ),
    path(
        "preferences/theme/",
        views.update_theme_preference,
        name="update_theme_preference",
    ),
    # Notification settings endpoints
    path(
        "settings/notifications/",
        views.get_notification_settings,
        name="get_notification_settings",
    ),
    path(
        "settings/notifications/update/",
        views.update_notification_settings,
        name="update_notification_settings",
    ),
    # Privacy settings endpoints
    path("settings/privacy/", views.get_privacy_settings, name="get_privacy_settings"),
    path(
        "settings/privacy/update/",
        views.update_privacy_settings,
        name="update_privacy_settings",
    ),
    # Security settings endpoints
    path("settings/security/", views.get_security_settings, name="get_security_settings"),
    path(
        "settings/security/update/",
        views.update_security_settings,
        name="update_security_settings",
    ),
    # User statistics endpoints
    path("statistics/", views.get_user_statistics, name="get_user_statistics"),
    # Top lists endpoints
    path("top-lists/", views.get_user_top_lists, name="get_user_top_lists"),
    path("top-lists/create/", views.create_top_list, name="create_top_list"),
    path("top-lists/<int:list_id>/", views.update_top_list, name="update_top_list"),
    path("top-lists/<int:list_id>/delete/", views.delete_top_list, name="delete_top_list"),
    # Notification endpoints
    path("notifications/", views.get_user_notifications, name="get_user_notifications"),
    path(
        "notifications/mark-read/",
        views.mark_notifications_read,
        name="mark_notifications_read",
    ),
    path(
        "notification-preferences/",
        views.get_notification_preferences,
        name="get_notification_preferences",
    ),
    path(
        "notification-preferences/update/",
        views.update_notification_preferences,
        name="update_notification_preferences",
    ),
    # Avatar endpoints
    path("profile/avatar/upload/", views.upload_avatar, name="upload_avatar"),
    path("profile/avatar/save/", views.save_avatar_image, name="save_avatar_image"),
    path("profile/avatar/delete/", views.delete_avatar, name="delete_avatar"),
    # User permissions endpoint
    path("permissions/", views.get_user_permissions, name="get_user_permissions"),
    # Login history endpoint
    path("login-history/", views.get_login_history, name="get_login_history"),
    # Email change cancellation endpoint
    path("email-change/cancel/", views.cancel_email_change, name="cancel_email_change"),
    # Magic Link (Login by Code) endpoints
    path("magic-link/request/", views_magic_link.request_magic_link, name="request_magic_link"),
    path("magic-link/verify/", views_magic_link.verify_magic_link, name="verify_magic_link"),
    # Public Profile
    path("profiles/<str:username>/", views.get_public_user_profile, name="get_public_user_profile"),
    # Bulk lookup endpoints
    path("profiles/bulk/", views.bulk_get_profiles, name="bulk_get_profiles"),
    path("users/bulk/", views.get_users_with_emails, name="get_users_with_emails"),
    # ViewSet routes
    path("", include(router.urls)),
]
