from enum import StrEnum
from django.utils.translation import gettext,gettext_lazy,gettext_noop as _

class WikiContentType(StrEnum):
    MARKDOWN = "markdown"
    BBCODE = "bbcode"
    
    @property
    def str_raw(self)->str:
        mapping = {
            WikiContentType.MARKDOWN: _("Markdown"),
            WikiContentType.BBCODE: _("BBCode")
        }
        return mapping[self]
    
    @staticmethod
    def from_string(string:str)->"WikiContentType":
        mapping = {
            WikiContentType.MARKDOWN.value: WikiContentType.MARKDOWN,
            WikiContentType.BBCODE.value: WikiContentType.BBCODE,
        }
        return mapping[string.lower()]
    
    @property
    def str_lazy(self)->str:
        return gettext_lazy(self.str_raw)
    
    @property
    def str(self)->str:
        return gettext(self.str_raw)
    
    def __str__(self):
        return self.str
    
    def __repr__(self):
        return f"<{self.__qualname__}: {self.value.upper()}>"

WIKI_CONTENT_TYPES = (
    WikiContentType.MARKDOWN,
    WikiContentType.BBCODE,
)
    
class WikiPageStatus(StrEnum):
    IN_PROGRESS = "in_progress"
    DRAFT = "draft"
    PUBLISHED = "published"
    
    @staticmethod
    def from_string(string:str)->"WikiPageStatus":
        mapping = {
            WikiPageStatus.IN_PROGRESS.value: WikiPageStatus.IN_PROGRESS,
            WikiPageStatus.DRAFT.value: WikiPageStatus.DRAFT,
            WikiPageStatus.PUBLISHED: WikiPageStatus.PUBLISHED,
        }
        return mapping[string.lower()]
    
    @property
    def str_raw(self)->str:
        mapping = {
            WikiPageStatus.IN_PROGRESS: _("in progress"),
            WikiPageStatus.DRAFT: _("draft"),
            WikiPageStatus.PUBLISHED: _("published"),
        }
        return mapping[self]
    
    
    
    @property
    def str_lazy(self)->str:
        return gettext_lazy(self.str_raw)
    
    @property
    def str(self)->str:
        return gettext(self.str_raw)
    
    def __str__(self):
        return self.str
    
    def __repr__(self):
        return f"<{self.__qualname__}: {self.value.upper()}>"

WIKI_PAGE_STATUS = (
    WikiPageStatus.IN_PROGRESS,
    WikiPageStatus.DRAFT,
    WikiPageStatus.PUBLISHED,
)