from __future__ import annotations

from enum import StrEnum

from app.enums.generation_task import ChatGenerationTaskStatus, GenerationMode


class RecentGenerationModuleEnum(StrEnum):
    """最近生成记录接口支持的模块分组枚举。"""

    PROJECT = "project"
    CHAT_AI = "chat_ai"
    HOT_OPENING_REPLICATE = "hot_opening_replicate"
    SHOT_REPLICATE = "shot_replicate"


class RecentGenerationResourceTypeEnum(StrEnum):
    """最近生成记录接口返回的资源类型枚举。"""

    IMAGE = "image"
    VIDEO = "video"


RECENT_GENERATION_ALL_MODULES: tuple[RecentGenerationModuleEnum, ...] = (
    RecentGenerationModuleEnum.PROJECT,
    RecentGenerationModuleEnum.CHAT_AI,
    RecentGenerationModuleEnum.HOT_OPENING_REPLICATE,
    RecentGenerationModuleEnum.SHOT_REPLICATE,
)
"""最近生成记录接口默认查询的全部模块。"""


RECENT_GENERATION_CHAT_TASK_MODULES: tuple[RecentGenerationModuleEnum, ...] = (
    RecentGenerationModuleEnum.CHAT_AI,
    RecentGenerationModuleEnum.HOT_OPENING_REPLICATE,
    RecentGenerationModuleEnum.SHOT_REPLICATE,
)
"""来自 chat_generation_tasks 表的模块集合。"""


RECENT_GENERATION_MODULE_TO_TASK_MODE: dict[RecentGenerationModuleEnum, GenerationMode] = {
    RecentGenerationModuleEnum.CHAT_AI: GenerationMode.CHATAPI_ASYNC,
    RecentGenerationModuleEnum.HOT_OPENING_REPLICATE: GenerationMode.HOT_OPENING_REPLICATE,
    RecentGenerationModuleEnum.SHOT_REPLICATE: GenerationMode.SHOT_REPLICATE,
}
"""最近生成记录模块枚举到 ChatGenerationTask.generation_mode 的映射。"""


RECENT_GENERATION_TASK_MODE_VALUE_TO_MODULE: dict[str, RecentGenerationModuleEnum] = {
    task_mode.value: module
    for module, task_mode in RECENT_GENERATION_MODULE_TO_TASK_MODE.items()
}
"""ChatGenerationTask.generation_mode 字符串值到最近生成记录模块枚举的映射。"""


RECENT_GENERATION_COMPLETED_STATUS = ChatGenerationTaskStatus.COMPLETED.value
"""最近生成记录只展示生成成功的数据，状态值与 ChatGenerationTaskStatus.COMPLETED 保持一致。"""