from typing import Any

from django.templatetags.static import static
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _

from evibes.settings.base import (
    LANGUAGES as BASE_LANGUAGES,
)
from evibes.settings.base import (
    LANGUAGES_FLAGS,
    PROJECT_NAME,
    STOREFRONT_DOMAIN,
    SUPPORT_CONTACT,
    TASKBOARD_URL,
)

UNFOLD: dict[str, Any] = {
    "SITE_URL": STOREFRONT_DOMAIN,
    "SITE_TITLE": f"{PROJECT_NAME} Dashboard",
    "SITE_HEADER": PROJECT_NAME,
    "SITE_LOGO": "favicon.png",
    "SITE_ICON": "favicon.ico",
    "SITE_SYMBOL": "money",
    "SITE_DROPDOWN": [
        {
            "icon": "diamond",
            "title": _("My site"),
            "link": f"https://{STOREFRONT_DOMAIN}",
            "attrs": {
                "target": "_blank",
            },
        },
        {
            "icon": "health_metrics",
            "title": _("Health"),
            "link": reverse_lazy("health_check:health_check_home"),
        },
        {
            "title": _("Support"),
            "icon": "contact_support",
            "link": SUPPORT_CONTACT,
        },
    ],
    "SHOW_LANGUAGES": True,
    "SHOW_VIEW_ON_SITE": False,
    "LOGIN": {
        "image": lambda request: static("favicon.png"),
    },
    "COMMAND": {
        "search_models": True,
        "show_history": True,
    },
    "DASHBOARD_CALLBACK": "engine.core.views.dashboard_callback",
    "LANGUAGES": {
        "navigation": [
            {
                "bidi": code.split("-")[0] in {"ar", "he", "fa", "ur"},
                "code": code,
                "name": LANGUAGES_FLAGS.get(code),
                "name_local": name,
                "name_translated": _(name),
            }
            for code, name in BASE_LANGUAGES
        ],
    },
    "EXTENSIONS": {
        "modeltranslation": {
            "flags": LANGUAGES_FLAGS,
        },
    },
    "SIDEBAR": {
        "show_search": True,
        "show_all_applications": True,
        "navigation": [
            {
                "title": _("Menu"),
                "separator": True,
                "collapsible": False,
                "items": [
                    {
                        "title": _("Dashboard"),
                        "icon": "dashboard",
                        "link": reverse_lazy("admin:index"),
                    },
                    {
                        "title": _("Config"),
                        "icon": "construction",
                        "link": reverse_lazy("admin:core_config_changelist"),
                    },
                    {
                        "title": _("Periodic Tasks"),
                        "icon": "event_list",
                        "link": reverse_lazy(
                            "admin:django_celery_beat_periodictask_changelist"
                        ),
                    },
                    {
                        "title": "Sitemap",
                        "icon": "rss_feed",
                        "link": reverse_lazy("core:sitemap-index"),
                    },
                    {
                        "title": "Swagger",
                        "icon": "integration_instructions",
                        "link": reverse_lazy("swagger-ui-platform"),
                    },
                    {
                        "title": "Redoc",
                        "icon": "integration_instructions",
                        "link": reverse_lazy("redoc-ui-platform"),
                    },
                    {
                        "title": "GraphQL",
                        "icon": "graph_5",
                        "link": reverse_lazy("graphql-platform"),
                    },
                    {
                        "title": _("Taskboard"),
                        "icon": "view_kanban",
                        "link": TASKBOARD_URL,
                    },
                    {
                        "title": "Documentation",
                        "icon": "book_2",
                        "link": reverse_lazy("django-admindocs-docroot"),
                    },
                ],
            },
            {
                "title": _("Quick Links"),
                "separator": True,
                "collapsible": False,
                "items": [
                    {
                        "title": _("Users"),
                        "icon": "person",
                        "link": reverse_lazy("admin:vibes_auth_user_changelist"),
                    },
                    {
                        "title": _("Groups"),
                        "icon": "people",
                        "link": reverse_lazy("admin:vibes_auth_group_changelist"),
                    },
                    {
                        "title": _("Orders"),
                        "icon": "package",
                        "link": reverse_lazy("admin:core_order_changelist"),
                    },
                    {
                        "title": _("Products"),
                        "icon": "storefront",
                        "link": reverse_lazy("admin:core_product_changelist"),
                    },
                    {
                        "title": _("Categories"),
                        "icon": "category",
                        "link": reverse_lazy("admin:core_category_changelist"),
                    },
                    {
                        "title": _("Brands"),
                        "icon": "copyright",
                        "link": reverse_lazy("admin:core_brand_changelist"),
                    },
                    {
                        "title": _("Blogposts"),
                        "icon": "newspaper",
                        "link": reverse_lazy("admin:blog_post_changelist"),
                    },
                ],
            },
        ],
    },
}
