# shellcheck shell=dash disable=1091,2034
# Thank and salute Oh My Zsh "ys" theme creator Yad Smood (https://github.com/ysmood)
# Inspired by ys (https://github.com/ohmyzsh/ohmyzsh/wiki/Themes#ys) and modified the theme format

___x_cmd_theme_prompt_format(){
    ___x_cmd_theme_ucvts "$@"
}

___x_cmd_theme_ucvts(){
   case "$1" in
        mini)   ___x_cmd_theme_ucvts_mini      ;;
        *)      ___x_cmd_theme_ucvts_normal    ;;
   esac
}

___x_cmd_theme_ucvts_mini(){
    XTW_cwd1_style_tail="${XTW_cwd_style_tail}"
    ___x_cmd_theme_mini
}

xrc:theme:widget msg symbol
___x_cmd_theme_ucvts_normal(){
    local x_;
    ___x_cmd_theme_headline_print

    ___x_cmd_theme_ucvts_left
    ___x_cmd_theme_ucvts_right
    local X_prompt="${X_left} ${X_right}"

    ______x_cmd_theme_prompt_remove_escapes_ "$X_prompt"
    if [ -n "$COLUMNS" ] && [ "${#x_}" -gt "$((  COLUMNS - COLUMNS / 3 ))" ]; then
        printf "%s\n"   "$X_right"
        printf "%s"     "$X_left"
    else
        printf "%s"     "$X_prompt"     # Using double column as a flavour
    fi

    ___x_cmd_theme_widget_symbol
    printf "\n%s " "${X_symbol}"
}

xrc:theme:widget cwd vcml username emoji
___x_cmd_theme_ucvts_left(){
    ___x_cmd_theme_widget_cwd
    ___x_cmd_theme_widget_vcml
    ___x_cmd_theme_widget_username
    ___x_cmd_theme_widget_emoji

    X_left="${X_emoji:+"${X_emoji}  "}${X_username} ${X_cwd} ${X_vcml}"
}

xrc:theme:widget hms hosttag
___x_cmd_theme_ucvts_right(){
    ___x_cmd_theme_widget_hms
    X_right="${X_hms}"

    # if [ -n "${x_docker}${x_ssh}${x_htag_server}" ] && [ -z "$x_tmux" ]; then
    #     ___x_cmd_theme_widget_hosttag
    #     [ -z "$X_hosttag" ] ||  X_right="${X_hosttag} ${X_right}"
    # fi
}

XTW_hms_text_prefix="["
XTW_hms_text_suffix="]"
XTW_vcml_left_label_clean=""
XTW_vcml_left_label_dirty=""
XTW_vcml_right_label_clean=" o"
XTW_vcml_right_label_dirty=" x"

XTW_cwd_style_trunk="bold yellow"
XTW_cwd_style_tail="yellow"
XTW_cwd_style_sep="dim"
XTW_cwd_sep=/
XTW_cwd_style_root="red"
XTW_cwd_style_rootfolder="yellow"

XTW_username_style_at="dim"

XTW_vcml_prefix='on git:'

___x_cmd_theme_linecount_ps1=3
