# shellcheck shell=dash

___x_cmd_jq_co(){
    :
    # Get the data to the output
    local o; o="$(cat)"

    local l="${#o}"

    # 1024 in the future, it should be 2048
    if [ "$l" -le 1024 ]; then
        x co --attachment input.data "$o" --prompt "$@"
    else
        local id
        x ui select id "Data exceess 4K"    \
            "Generate the schema"           \
            "heading 1K data"               \
            "Exit"

        case "$id" in
            1)
                # using schema
                # uploading the data
                o="$(___x_cmd_piepvar o  head -c 1024)"
                x co --attachment input.data.first1024b "$o" --prompt "$@"
                ;;
            2)
                o="$(___x_cmd_piepvar o  head -c 1024)"
                x co --attachment input.data.first1024b "$o" --prompt "$@"
                ;;
            *)
                return ;;
        esac
    fi
}

# multiple tools:
# try to minimize the data into schema
# check the lines of file -- from line XX to line XY
# generate the schema of the first level
