# shellcheck shell=dash

# Section: theme global variable setup
xrc:mod:lib theme     style/style_variable

___X_CMD_THEME_NEWLINE="
"

___x_cmd_theme_set___color_code() {
    case "$1" in
        black)      color_code=0                ;;
        red)        color_code=1                ;;
        green)      color_code=2                ;;
        yellow)     color_code=3                ;;
        blue)       color_code=4                ;;
        magenta)    color_code=5                ;;
        cyan)       color_code=6                ;;
        white)      color_code=7                ;;
        colour*)    color_code="${1#colour}"    ;;
    esac
}

___x_cmd_theme_set___rgb_color_code() {
    color_code="${1#\#}"
    local ___x_cmd_theme_R="${color_code%????*}"
    color_code="${color_code#??}"
    local ___x_cmd_theme_G="${color_code%??*}"
    color_code="${color_code#??}"

    color_code="$((0x${___x_cmd_theme_R}));$((0x${___x_cmd_theme_G}));$((0x${color_code}))"
}

# EndSection

# Section: style setup
## Enable our easy to read Colour Flags as long as the NO_COLOR Env Variable is set.
## NOTE: the NO_COLOR env variable is from: https://no-color.org/
if [ -n "${NO_COLOR}" ]; then
    xrc:mod:lib theme     style/style_no_color
elif [ -n "$ZSH_VERSION" ]; then
    xrc:mod:lib theme     style/style_zsh       style/style_set_theme_color
else
    xrc:mod:lib theme     style/style_posix     style/style_set_theme_color
fi

alias theme:color="___x_cmd_theme_set_theme_color"
# EndSection

alias theme:style_=___x_cmd_theme_style_
