#compdef boundbook

autoload -U is-at-least

_boundbook() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_boundbook_commands" \
"*::: :->boundbook" \
&& ret=0
    case $state in
    (boundbook)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:boundbook-command-$line[1]:"
        case $line[1] in
            (docs)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(create)
_arguments "${_arguments_options[@]}" : \
'-o+[Output BBF file path]:OUTPUT:_files' \
'--output=[Output BBF file path]:OUTPUT:_files' \
'-O+[Page order file (format\: filename\:index)]:ORDER:_files' \
'--order=[Page order file (format\: filename\:index)]:ORDER:_files' \
'-S+[Sections file (format\: Name\:Target\[\:Parent\])]:SECTIONS:_files' \
'--sections=[Sections file (format\: Name\:Target\[\:Parent\])]:SECTIONS:_files' \
'*-s+[Add section markers (format\: Name\:Target\[\:Parent\])]:ADD_SECTIONS:_default' \
'*--section=[Add section markers (format\: Name\:Target\[\:Parent\])]:ADD_SECTIONS:_default' \
'*-m+[Add metadata (format\: Key\:Value\[\:Parent\])]:METADATA:_default' \
'*--meta=[Add metadata (format\: Key\:Value\[\:Parent\])]:METADATA:_default' \
'-a+[Byte alignment exponent (default\: 12 = 4096 bytes)]:ALIGNMENT:_default' \
'--alignment=[Byte alignment exponent (default\: 12 = 4096 bytes)]:ALIGNMENT:_default' \
'-r+[Ream size exponent (default\: 16 = 65536 bytes)]:REAM_SIZE:_default' \
'--ream-size=[Ream size exponent (default\: 16 = 65536 bytes)]:REAM_SIZE:_default' \
'-v[Enable variable ream size for smaller files]' \
'--variable-ream-size[Enable variable ream size for smaller files]' \
'-d[Auto-detect subdirectories with images and create sections from directory names]' \
'--auto-detect-sections[Auto-detect subdirectories with images and create sections from directory names]' \
'-h[Print help]' \
'--help[Print help]' \
'*::inputs -- Input files or directories containing images:_files' \
&& ret=0
;;
(info)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':input:_files' \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" : \
'(--index-only)--asset=[Verify a specific asset by index]:ASSET:_default' \
'--index-only[Verify only the index hash (faster)]' \
'-h[Print help]' \
'--help[Print help]' \
':input -- BBF file to verify:_files' \
&& ret=0
;;
(extract)
_arguments "${_arguments_options[@]}" : \
'-o+[Output directory for extracted pages]:OUTPUT:_files' \
'--output=[Output directory for extracted pages]:OUTPUT:_files' \
'--section=[Extract only pages from a specific section]:SECTION:_default' \
'--until=[Stop extraction when reaching a section matching this string]:UNTIL:_default' \
'(--section)--range=[Extract a specific page range (e.g., 1-10 or 5)]:RANGE:_default' \
'-h[Print help]' \
'--help[Print help]' \
':input -- BBF file to extract from:_files' \
&& ret=0
;;
(from-cbz)
_arguments "${_arguments_options[@]}" : \
'-o+[Output BBF file]:OUTPUT:_files' \
'--output=[Output BBF file]:OUTPUT:_files' \
'*-m+[Add metadata (format\: Key\:Value\[\:Parent\])]:METADATA:_default' \
'*--meta=[Add metadata (format\: Key\:Value\[\:Parent\])]:METADATA:_default' \
'-k[Keep temporary files for debugging]' \
'--keep-temp[Keep temporary files for debugging]' \
'-d[Process directory of CBZ files as chapters]' \
'--directory-mode[Process directory of CBZ files as chapters]' \
'-h[Print help]' \
'--help[Print help]' \
':input -- Input CBZ file or directory containing CBZ files:_files' \
&& ret=0
;;
(read)
_arguments "${_arguments_options[@]}" : \
'-W+[Maximum width in pixels (aspect ratio preserved)]:PIXELS:_default' \
'--max-width=[Maximum width in pixels (aspect ratio preserved)]:PIXELS:_default' \
'-H+[Maximum height in pixels (aspect ratio preserved)]:PIXELS:_default' \
'--max-height=[Maximum height in pixels (aspect ratio preserved)]:PIXELS:_default' \
'--max-cols=[Maximum width in terminal columns (overrides max-width if set)]:COLS:_default' \
'--max-rows=[Maximum height in terminal rows (overrides max-height if set)]:ROWS:_default' \
'-f+[Image scaling filter quality]:FILTER:(nearest triangle catmull-rom gaussian lanczos3)' \
'--filter=[Image scaling filter quality]:FILTER:(nearest triangle catmull-rom gaussian lanczos3)' \
'--gif-speed=[GIF animation frame delay multiplier (1.0 = normal speed)]:MULTIPLIER:_default' \
'-i+[Number of interpolated frames to generate between each GIF frame (0 = disabled)]:COUNT:_default' \
'--gif-interpolate=[Number of interpolated frames to generate between each GIF frame (0 = disabled)]:COUNT:_default' \
'-m+[Frame interpolation algorithm]:INTERPOLATION_METHOD:((blend\:"Simple linear blending (fastest)"
smooth\:"Weighted blending with ease-in/ease-out"
cosine\:"Cosine interpolation for smoother transitions"
cubic\:"Cubic hermite spline interpolation"
perlin\:"Perlin smoothstep (quintic hermite)"
exponential\:"Exponential ease-in-out"
optical-flow-sparse\:"Optical flow based (Lucas-Kanade sparse)"
motion-compensated\:"Motion-compensated blending (simplified Horn-Schunck)"
catmull-rom\:"Catmull-Rom spline (requires 4 frames, falls back to cubic)"))' \
'--interpolation-method=[Frame interpolation algorithm]:INTERPOLATION_METHOD:((blend\:"Simple linear blending (fastest)"
smooth\:"Weighted blending with ease-in/ease-out"
cosine\:"Cosine interpolation for smoother transitions"
cubic\:"Cubic hermite spline interpolation"
perlin\:"Perlin smoothstep (quintic hermite)"
exponential\:"Exponential ease-in-out"
optical-flow-sparse\:"Optical flow based (Lucas-Kanade sparse)"
motion-compensated\:"Motion-compensated blending (simplified Horn-Schunck)"
catmull-rom\:"Catmull-Rom spline (requires 4 frames, falls back to cubic)"))' \
'--sidebar-width=[Sidebar width in columns]:SIDEBAR_WIDTH:_default' \
'--slideshow-delay=[Slideshow auto-advance delay in seconds]:SECONDS:_default' \
'-P[Pre-render all pages before reading (uses more memory but smoother navigation)]' \
'--prerender[Pre-render all pages before reading (uses more memory but smoother navigation)]' \
'-g[Enable GIF animation playback]' \
'--enable-gif-animation[Enable GIF animation playback]' \
'-l[Loop GIFs infinitely]' \
'--gif-loop[Loop GIFs infinitely]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':input -- BBF file to read:_files' \
&& ret=0
;;
(complete)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash elvish fish power-shell zsh nushell clink fig)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_boundbook__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:boundbook-help-command-$line[1]:"
        case $line[1] in
            (docs)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(create)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(info)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(verify)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(extract)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(from-cbz)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(read)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(complete)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_boundbook_commands] )) ||
_boundbook_commands() {
    local commands; commands=(
'docs:Print help' \
'create:Create a BBF file from images' \
'info:Display BBF file information' \
'verify:Verify BBF file integrity' \
'extract:Extract pages from a BBF file' \
'from-cbz:Convert CBZ archive to BBF format' \
'read:Read a BBF file in the terminal' \
'complete:Generate CLI completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'boundbook commands' commands "$@"
}
(( $+functions[_boundbook__complete_commands] )) ||
_boundbook__complete_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook complete commands' commands "$@"
}
(( $+functions[_boundbook__create_commands] )) ||
_boundbook__create_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook create commands' commands "$@"
}
(( $+functions[_boundbook__docs_commands] )) ||
_boundbook__docs_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook docs commands' commands "$@"
}
(( $+functions[_boundbook__extract_commands] )) ||
_boundbook__extract_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook extract commands' commands "$@"
}
(( $+functions[_boundbook__from-cbz_commands] )) ||
_boundbook__from-cbz_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook from-cbz commands' commands "$@"
}
(( $+functions[_boundbook__help_commands] )) ||
_boundbook__help_commands() {
    local commands; commands=(
'docs:Print help' \
'create:Create a BBF file from images' \
'info:Display BBF file information' \
'verify:Verify BBF file integrity' \
'extract:Extract pages from a BBF file' \
'from-cbz:Convert CBZ archive to BBF format' \
'read:Read a BBF file in the terminal' \
'complete:Generate CLI completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'boundbook help commands' commands "$@"
}
(( $+functions[_boundbook__help__complete_commands] )) ||
_boundbook__help__complete_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help complete commands' commands "$@"
}
(( $+functions[_boundbook__help__create_commands] )) ||
_boundbook__help__create_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help create commands' commands "$@"
}
(( $+functions[_boundbook__help__docs_commands] )) ||
_boundbook__help__docs_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help docs commands' commands "$@"
}
(( $+functions[_boundbook__help__extract_commands] )) ||
_boundbook__help__extract_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help extract commands' commands "$@"
}
(( $+functions[_boundbook__help__from-cbz_commands] )) ||
_boundbook__help__from-cbz_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help from-cbz commands' commands "$@"
}
(( $+functions[_boundbook__help__help_commands] )) ||
_boundbook__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help help commands' commands "$@"
}
(( $+functions[_boundbook__help__info_commands] )) ||
_boundbook__help__info_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help info commands' commands "$@"
}
(( $+functions[_boundbook__help__read_commands] )) ||
_boundbook__help__read_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help read commands' commands "$@"
}
(( $+functions[_boundbook__help__verify_commands] )) ||
_boundbook__help__verify_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook help verify commands' commands "$@"
}
(( $+functions[_boundbook__info_commands] )) ||
_boundbook__info_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook info commands' commands "$@"
}
(( $+functions[_boundbook__read_commands] )) ||
_boundbook__read_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook read commands' commands "$@"
}
(( $+functions[_boundbook__verify_commands] )) ||
_boundbook__verify_commands() {
    local commands; commands=()
    _describe -t commands 'boundbook verify commands' commands "$@"
}

if [ "$funcstack[1]" = "_boundbook" ]; then
    _boundbook "$@"
else
    compdef _boundbook boundbook
fi
