# Path: mqueue/conf.py
# EVENT_CLASSES = {
#     # 'Event class label': 'css class to apply',
#     "Default": "mq-label mq-default",
#     "Important": "mq-label mq-important",
#     "Ok": "mq-label mq-ok",
#     "Info": "mq-label mq-info",
#     "Debug": "mq-label mq-debug",
#     "Warning": "mq-label mq-warning",
#     "Error": "mq-label mq-error",
#     "Object created": "mq-label mq-created",
#     "Object edited": "mq-label mq-edited",
#     "Object deleted": "mq-label mq-deleted",
# }
# 
# EVENT_DEFAULT_BADGES = {
#     "Default": {
#         "css": {"background-color": "firebrick", "color": "white"},
#         "icon": "fa fa-flash",
#     },
#     "Important": {
#         "css": {"background-color": "firebrick", "color": "white"},
#         "icon": "fa fa-exclamation",
#     },
#     "Ok": {
#         "css": {"background-color": "forestgreen", "color": "white"},
#         "icon": "fa fa-thumbs-up",
#     },
#     "Info": {
#         "css": {"background-color": "royalblue", "color": "white"},
#         "icon": "fa fa-info-circle",
#     },
#     "Debug": {
#         "css": {"background-color": "orange", "color": "black"},
#         "icon": "fa fa-cog",
#     },
#     "Warning": {
#         "css": {"background-color": "yellow", "color": "black"},
#         "icon": "fa fa-exclamation",
#     },
#     "Error": {
#         "css": {"background-color": "red", "color": "black"},
#         "icon": "fa fa-exclamation-triangle",
#     },
#     "Object created": {
#         "css": {"background-color": "darkcyan", "color": "white"},
#         "icon": "fa fa-plus",
#     },
#     "Object edited": {
#         "css": {"background-color": "dodgerblue", "color": "white"},
#         "icon": "fa fa-pencil",
#     },
#     "Object deleted": {
#         "css": {"background-color": "lightcoral", "color": "white"},
#         "icon": "fa fa-remove",
#     },
# }
# 
# EVENT_EXTRA_HTML: Dict[str, str] = getattr(settings, "MQUEUE_EVENT_EXTRA_HTML", {})
# 
# EVENT_ICONS_HTML = {
#     # 'Event class label': 'icon css class',
#     "Default": '<i class="fa fa-flash"></i>',
#     "Important": '<i class="fa fa-exclamation"></i>',
#     "Ok": '<i class="fa fa-thumbs-up"></i>',
#     "Info": '<i class="fa fa-info-circle"></i>',
#     "Debug": '<i class="fa fa-cog"></i>',
#     "Warning": '<i class="fa fa-exclamation"></i>',
#     "Error": '<i class="fa fa-exclamation-triangle"></i>',
#     "Object edited": '<i class="fa fa-pencil"></i>',
#     "Object created": '<i class="fa fa-plus"></i>',
#     "Object deleted": '<i class="fa fa-remove"></i>',
# }


from typing import Union
from django.contrib.auth.models import User
from django.db.models.base import Model
from django.urls import reverse
from .conf import (
    EVENT_CLASSES,
    EVENT_DEFAULT_BADGES,
    EVENT_EXTRA_HTML,
    EVENT_ICONS_HTML,
)




def get_event_class_str(event_class: Union[str, None] = None) -> str:
    event_class_str = "Default"
    if event_class is not None:
        if "created" in event_class:
            event_class_str = "Object created"
        if "deleted" in event_class:
            event_class_str = "Object deleted"
        if "edited" in event_class:
            event_class_str = "Object edited"
    return event_class_str


def get_event_badge(obj) -> str:  # type: ignore
    """
    Get a badge html for an event
    """
    hasFormater = getattr(obj, "event_badge", None)
    if hasFormater:
        return obj.event_badge  # type: ignore
    formated_event_class = get_event_class_str(str(obj.event_class))
    icon = EVENT_DEFAULT_BADGES["Default"]["icon"]
    name: str = str(obj.event_class)
    if name is None:
        name = get_event_class_str(str(obj.event_class))
    if formated_event_class in EVENT_DEFAULT_BADGES.keys():

# Path: mqueue/conf.py
# EVENT_CLASSES = {
#     # 'Event class label': 'css class to apply',
#     "Default": "mq-label mq-default",
#     "Important": "mq-label mq-important",
#     "Ok": "mq-label mq-ok",
#     "Info": "mq-label mq-info",
#     "Debug": "mq-label mq-debug",
#     "Warning": "mq-label mq-warning",
#     "Error": "mq-label mq-error",
#     "Object created": "mq-label mq-created",
#     "Object edited": "mq-label mq-edited",
#     "Object deleted": "mq-label mq-deleted",
# }
# 
# EVENT_DEFAULT_BADGES = {
#     "Default": {
#         "css": {"background-color": "firebrick", "color": "white"},
#         "icon": "fa fa-flash",
#     },
#     "Important": {
#         "css": {"background-color": "firebrick", "color": "white"},
#         "icon": "fa fa-exclamation",
#     },
#     "Ok": {
#         "css": {"background-color": "forestgreen", "color": "white"},
#         "icon": "fa fa-thumbs-up",
#     },
#     "Info": {
#         "css": {"background-color": "royalblue", "color": "white"},
#         "icon": "fa fa-info-circle",
#     },
#     "Debug": {
#         "css": {"background-color": "orange", "color": "black"},
#         "icon": "fa fa-cog",
#     },
#     "Warning": {
#         "css": {"background-color": "yellow", "color": "black"},
#         "icon": "fa fa-exclamation",
#     },
#     "Error": {
#         "css": {"background-color": "red", "color": "black"},
#         "icon": "fa fa-exclamation-triangle",
#     },
#     "Object created": {
#         "css": {"background-color": "darkcyan", "color": "white"},
#         "icon": "fa fa-plus",
#     },
#     "Object edited": {
#         "css": {"background-color": "dodgerblue", "color": "white"},
#         "icon": "fa fa-pencil",
#     },
#     "Object deleted": {
#         "css": {"background-color": "lightcoral", "color": "white"},
#         "icon": "fa fa-remove",
#     },
# }
# 
# EVENT_EXTRA_HTML: Dict[str, str] = getattr(settings, "MQUEUE_EVENT_EXTRA_HTML", {})
# 
# EVENT_ICONS_HTML = {
#     # 'Event class label': 'icon css class',
#     "Default": '<i class="fa fa-flash"></i>',
#     "Important": '<i class="fa fa-exclamation"></i>',
#     "Ok": '<i class="fa fa-thumbs-up"></i>',
#     "Info": '<i class="fa fa-info-circle"></i>',
#     "Debug": '<i class="fa fa-cog"></i>',
#     "Warning": '<i class="fa fa-exclamation"></i>',
#     "Error": '<i class="fa fa-exclamation-triangle"></i>',
#     "Object edited": '<i class="fa fa-pencil"></i>',
#     "Object created": '<i class="fa fa-plus"></i>',
#     "Object deleted": '<i class="fa fa-remove"></i>',
# }


# Path: mqueue/utils.py
from typing import Union
from django.contrib.auth.models import User
from django.db.models.base import Model
from django.urls import reverse
from .conf import (
    EVENT_CLASSES,
    EVENT_DEFAULT_BADGES,
    EVENT_EXTRA_HTML,
    EVENT_ICONS_HTML,
)





def get_event_class_str(event_class: Union[str, None] = None) -> str:
    event_class_str = "Default"
    if event_class is not None:
        if "created" in event_class:
            event_class_str = "Object created"
        if "deleted" in event_class:
            event_class_str = "Object deleted"
        if "edited" in event_class:
            event_class_str = "Object edited"
    return event_class_str


def get_event_badge(obj) -> str:  # type: ignore
    """
    Get a badge html for an event
    """
    hasFormater = getattr(obj, "event_badge", None)
    if hasFormater:
        return obj.event_badge  # type: ignore
    formated_event_class = get_event_class_str(str(obj.event_class))
    icon = EVENT_DEFAULT_BADGES["Default"]["icon"]
    name: str = str(obj.event_class)
    if name is None:
        name = get_event_class_str(str(obj.event_class))
    if formated_event_class in EVENT_DEFAULT_BADGES.keys():

        icon = EVENT_DEFAULT_BADGES[formated_event_class]["icon"]