"""类型定义模块"""

from typing import Dict, Any, Literal, Union
from dataclasses import dataclass
from enum import Enum


@dataclass
class PixelFormat:
    """像素格式信息"""

    bits_per_pixel: int
    depth: int
    big_endian: bool
    true_colour: bool
    red_max: int
    green_max: int
    blue_max: int
    red_shift: int
    green_shift: int
    blue_shift: int


@dataclass
class ServerInfo:
    """服务器信息"""

    width: int
    height: int
    pixel_format: PixelFormat
    server_name: str


@dataclass
class Rectangle:
    """矩形区域"""

    x: int
    y: int
    width: int
    height: int
    encoding: int


# 鼠标按钮类型
MouseButton = Literal["left", "right", "middle"]

# 滚轮方向
ScrollDirection = Literal["up", "down"]

# 连接配置
ConnectionConfig = Dict[str, Any]


class SpecialKey(Enum):
    """特殊按键枚举

    定义了所有支持的特殊按键名称，包括：
    - 导航键（方向键、Home、End等）
    - 功能键（F1-F12）
    - 修饰键（Ctrl、Alt、Shift、Win）
    - 编辑键（Backspace、Delete、Insert等）
    """

    # 导航键
    BACKSPACE = "backspace"
    TAB = "tab"
    RETURN = "return"
    ENTER = "enter"  # 与 RETURN 相同
    ESCAPE = "escape"
    DELETE = "delete"
    HOME = "home"
    END = "end"
    INSERT = "insert"
    LEFT = "left"
    UP = "up"
    RIGHT = "right"
    DOWN = "down"
    PAGE_UP = "page_up"
    PAGE_DOWN = "page_down"

    # 功能键
    F1 = "f1"
    F2 = "f2"
    F3 = "f3"
    F4 = "f4"
    F5 = "f5"
    F6 = "f6"
    F7 = "f7"
    F8 = "f8"
    F9 = "f9"
    F10 = "f10"
    F11 = "f11"
    F12 = "f12"

    # 修饰键
    SHIFT = "shift"
    SHIFT_L = "shift_l"
    SHIFT_R = "shift_r"
    CTRL = "ctrl"
    CTRL_L = "ctrl_l"
    CTRL_R = "ctrl_r"
    ALT = "alt"
    ALT_L = "alt_l"
    ALT_R = "alt_r"
    WIN = "win"
    WIN_L = "win_l"
    WIN_R = "win_r"
    WINDOWS = "windows"  # 与 WIN 相同
    SUPER = "super"  # 与 WIN 相同


# 按键类型：可以是普通字符、特殊按键枚举值或特殊按键字符串
KeyInput = Union[str, SpecialKey]

# 组合键序列类型
KeyCombination = tuple[KeyInput, ...]
