"""
Core app URL configuration.
"""

from django.urls import include, path

from ..views.entity_search import (
    EntityFuzzySearchView,
    EntityNotFoundView,
    QuickEntitySuggestionView,
)
from ..views.views import FSMTransitionView

app_name = "core"

# Entity search endpoints
entity_patterns = [
    path("search/", EntityFuzzySearchView.as_view(), name="entity_fuzzy_search"),
    path("not-found/", EntityNotFoundView.as_view(), name="entity_not_found"),
    path("suggestions/", QuickEntitySuggestionView.as_view(), name="entity_suggestions"),
]

# FSM transition endpoints
fsm_patterns = [
    # Generic FSM transition endpoint
    # URL: /core/fsm/<app_label>/<model_name>/<pk>/transition/<transition_name>/
    path(
        "<str:app_label>/<str:model_name>/<int:pk>/transition/<str:transition_name>/",
        FSMTransitionView.as_view(),
        name="fsm_transition",
    ),
    # Slug-based FSM transition endpoint for models that use slugs
    # URL: /core/fsm/<app_label>/<model_name>/by-slug/<slug>/transition/<transition_name>/
    path(
        "<str:app_label>/<str:model_name>/by-slug/<slug:slug>/transition/<str:transition_name>/",
        FSMTransitionView.as_view(),
        name="fsm_transition_by_slug",
    ),
]

urlpatterns = [
    # Entity fuzzy matching and search endpoints
    path("entities/", include(entity_patterns)),
    # FSM transition endpoints
    path("fsm/", include(fsm_patterns)),
    # Error monitoring endpoints (API)
    path("errors/", include("apps.core.urls.errors", namespace="errors")),
]
