#!/usr/bin/env bash
# Quarto CLI completions, generated by quarto-completions.
# Quarto 1.10.18 (1.10 channel).
# Do not edit: https://github.com/mcanouil/quarto-completions

_quarto_nodes="quarto quarto_render quarto_preview quarto_serve quarto_create quarto_use quarto_use_template quarto_use_binder quarto_use_brand quarto_add quarto_update quarto_remove quarto_convert quarto_pandoc quarto_typst quarto_run quarto_list quarto_install quarto_uninstall quarto_tools quarto_publish quarto_check quarto_call quarto_call_engine quarto_call_build_ts_extension quarto_call_typst_gather"

_quarto_words() {
  # Not compgen -W: it re-expands its wordlist, running any $(...) or `...`
  # a candidate carries rather than treating it as inert text, even one
  # that arrived here already escaped for this file's own parsing. Verified
  # against real bash. A plain, unquoted word-split of "$1" does not.
  #
  # set -f around it for the same reason: unquoted word-splitting still
  # performs pathname expansion, so a candidate that happens to look like a
  # glob, such as a real flag spelled with brackets, would otherwise be
  # replaced by whatever files match it in the current directory. Verified:
  # "P*" listed unrelated local files instead of completing as itself.
  local word
  set -f
  for word in $1; do
    case "$word" in
      "$cur"*) COMPREPLY+=("$word") ;;
    esac
  done
  set +f
}

_quarto_files() {
  local pattern="$1" enabled=0
  if [ -n "$pattern" ]; then
    # shopt -q is a builtin; reading the option with shopt -p needs a subshell.
    if ! shopt -q extglob; then
      shopt -s extglob
      enabled=1
    fi
    # shellcheck disable=SC2207
    COMPREPLY+=( $(compgen -f -X "!*.@($pattern)" -- "$cur"; compgen -d -- "$cur") )
    if [ "$enabled" = "1" ]; then
      shopt -u extglob
    fi
  else
    # shellcheck disable=SC2207
    COMPREPLY+=( $(compgen -f -- "$cur") )
  fi
  compopt -o filenames 2>/dev/null
}

_quarto_dirs() {
  # shellcheck disable=SC2207
  COMPREPLY+=( $(compgen -d -- "$cur") )
  compopt -o filenames 2>/dev/null
}

# Sets vals to the flags of a command that consume the word after them.
# Assigns rather than echoes, so walking the command line forks nothing.
_quarto_valued() {
  case "$1" in
    quarto_render) vals="-t --to -o --output --output-dir -M --metadata --site-url -P --execute-param --execute-params --execute-dir --execute-daemon --log --log-level --log-format --profile --toc-depth --number-offset --top-level-division --template --css --bibliography --csl --highlight-style --pdf-engine --wrap --reference-doc --shift-heading-level-by" ;;
    quarto_preview) vals="--port --host --render --timeout --log --log-level --log-format --profile --toc-depth --number-offset --top-level-division --template --css --bibliography --csl --highlight-style --pdf-engine --wrap --reference-doc --shift-heading-level-by" ;;
    quarto_serve) vals="-p --port --host --log --log-level --log-format --profile" ;;
    quarto_create) vals="--open --log --log-level --log-format --profile" ;;
    quarto_use_template) vals="--log --log-level --log-format" ;;
    quarto_use_binder) vals="--log --log-level --log-format" ;;
    quarto_use_brand) vals="--log --log-level --log-format --profile" ;;
    quarto_add) vals="--embed --log --log-level --log-format --profile" ;;
    quarto_update) vals="--embed --log --log-level --log-format --profile" ;;
    quarto_remove) vals="--embed --log --log-level --log-format --profile" ;;
    quarto_convert) vals="-o --output --log --log-level --log-format --profile" ;;
    quarto_run) vals="--log --log-level --log-format --profile" ;;
    quarto_list) vals="--log --log-level --log-format --profile" ;;
    quarto_install) vals="--log --log-level --log-format --profile" ;;
    quarto_uninstall) vals="--log --log-level --log-format --profile" ;;
    quarto_publish) vals="--id --server --token --log --log-level --log-format --profile" ;;
    quarto_check) vals="--output --log --log-level --log-format --profile" ;;
    quarto_call_engine) vals="--log --log-level --log-format" ;;
    quarto_call_build_ts_extension) vals="--log --log-level --log-format" ;;
    quarto_call_typst_gather) vals="--log --log-level --log-format --profile" ;;
    *) vals="" ;;
  esac
}

_quarto() {
  local cur prev cmd word key vals i pos skip words cword raw
  COMPREPLY=()

  # '=' and ':' are both in COMP_WORDBREAKS, so '--to=html' arrives as the
  # three words '--to', '=', 'html', and 'key:value' is split the same way.
  # Reassemble once; everything below reads the glued words.
  words=("${COMP_WORDS[0]}")
  cword=0
  for (( i=1; i <= COMP_CWORD; i++ )); do
    raw="${COMP_WORDS[i]}"
    if [[ "$raw" == [=:] ]] || [[ "${COMP_WORDS[i-1]}" == [=:] ]]; then
      words[${#words[@]}-1]="${words[${#words[@]}-1]}${raw}"
    else
      words[${#words[@]}]="$raw"
    fi
    if [ "$i" -eq "$COMP_CWORD" ]; then
      cword=$(( ${#words[@]} - 1 ))
    fi
  done

  cur="${words[cword]}"
  # bash 3.2 rejects a negative array subscript, so guard the first word.
  prev=""
  if [ "$cword" -gt 0 ]; then
    prev="${words[cword-1]}"
  fi
  # A flag with its value attached dispatches on the flag; the part after '='
  # is the word being completed.
  case "$cur" in
    -*=*)
      prev="${cur%%=*}"
      cur="${cur#*=}"
      ;;
  esac

  cmd="quarto"
  _quarto_valued "$cmd"
  pos=0
  skip=0
  for (( i=1; i < cword; i++ )); do
    word="${words[i]}"
    if [ "$skip" = "1" ]; then
      skip=0
      continue
    fi
    case "$word" in
      # A value attached with '=' travels inside the flag's own word.
      -*=*) continue ;;
      -*)
        case " $vals " in
          *" $word "*) skip=1 ;;
        esac
        continue
        ;;
    esac
    key="${cmd}_${word//[^A-Za-z0-9]/_}"
    case " $_quarto_nodes " in
      *" $key "*)
        cmd="$key"
        _quarto_valued "$cmd"
        pos=0
        continue
        ;;
    esac
    pos=$(( pos + 1 ))
  done

  # A flag that expects a value takes precedence over everything else.
  case "${cmd}:::${prev}" in
    quarto_render:::-t|quarto_render:::--to) _quarto_words "html pdf docx odt rtf revealjs beamer pptx typst dashboard epub gfm commonmark markdown markua hugo-md docusaurus-md jats asciidoc asciidoctor ipynb context docbook dokuwiki jira mediawiki man ms muse opml org rst texinfo textile xwiki zimwiki"; return ;;
    quarto_render:::-o|quarto_render:::--output) _quarto_files ""; return ;;
    quarto_render:::--output-dir) _quarto_dirs; return ;;
    quarto_render:::-M|quarto_render:::--metadata) :; return ;;
    quarto_render:::--site-url) :; return ;;
    quarto_render:::-P|quarto_render:::--execute-param) :; return ;;
    quarto_render:::--execute-params) _quarto_files "yml|yaml|json"; return ;;
    quarto_render:::--execute-dir) _quarto_dirs; return ;;
    quarto_render:::--execute-daemon) :; return ;;
    quarto_render:::--log) _quarto_files ""; return ;;
    quarto_render:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_render:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_render:::--profile) :; return ;;
    quarto_render:::--toc-depth) :; return ;;
    quarto_render:::--number-offset) :; return ;;
    quarto_render:::--top-level-division) _quarto_words "default section chapter part"; return ;;
    quarto_render:::--template) _quarto_files ""; return ;;
    quarto_render:::--css) _quarto_files "css"; return ;;
    quarto_render:::--bibliography) _quarto_files "bib|bibtex|json|yml|yaml"; return ;;
    quarto_render:::--csl) _quarto_files "csl"; return ;;
    quarto_render:::--highlight-style) :; return ;;
    quarto_render:::--pdf-engine) _quarto_words "pdflatex lualatex xelatex tectonic latexmk context wkhtmltopdf weasyprint typst"; return ;;
    quarto_render:::--wrap) _quarto_words "auto none preserve"; return ;;
    quarto_render:::--reference-doc) _quarto_files "docx|pptx|odt"; return ;;
    quarto_render:::--shift-heading-level-by) :; return ;;
    quarto_preview:::--port) :; return ;;
    quarto_preview:::--host) :; return ;;
    quarto_preview:::--render) _quarto_words "all html pdf docx odt rtf revealjs beamer pptx typst dashboard epub gfm commonmark markdown markua hugo-md docusaurus-md jats asciidoc asciidoctor ipynb context docbook dokuwiki jira mediawiki man ms muse opml org rst texinfo textile xwiki zimwiki"; return ;;
    quarto_preview:::--timeout) :; return ;;
    quarto_preview:::--log) _quarto_files ""; return ;;
    quarto_preview:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_preview:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_preview:::--profile) :; return ;;
    quarto_preview:::--toc-depth) :; return ;;
    quarto_preview:::--number-offset) :; return ;;
    quarto_preview:::--top-level-division) _quarto_words "default section chapter part"; return ;;
    quarto_preview:::--template) _quarto_files ""; return ;;
    quarto_preview:::--css) _quarto_files "css"; return ;;
    quarto_preview:::--bibliography) _quarto_files "bib|bibtex|json|yml|yaml"; return ;;
    quarto_preview:::--csl) _quarto_files "csl"; return ;;
    quarto_preview:::--highlight-style) :; return ;;
    quarto_preview:::--pdf-engine) _quarto_words "pdflatex lualatex xelatex tectonic latexmk context wkhtmltopdf weasyprint typst"; return ;;
    quarto_preview:::--wrap) _quarto_words "auto none preserve"; return ;;
    quarto_preview:::--reference-doc) _quarto_files "docx|pptx|odt"; return ;;
    quarto_preview:::--shift-heading-level-by) :; return ;;
    quarto_serve:::-p|quarto_serve:::--port) :; return ;;
    quarto_serve:::--host) :; return ;;
    quarto_serve:::--log) _quarto_files ""; return ;;
    quarto_serve:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_serve:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_serve:::--profile) :; return ;;
    quarto_create:::--open) _quarto_words "positron vscode rstudio"; return ;;
    quarto_create:::--log) _quarto_files ""; return ;;
    quarto_create:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_create:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_create:::--profile) :; return ;;
    quarto_use_template:::--log) _quarto_files ""; return ;;
    quarto_use_template:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_use_template:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_use_binder:::--log) _quarto_files ""; return ;;
    quarto_use_binder:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_use_binder:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_use_brand:::--log) _quarto_files ""; return ;;
    quarto_use_brand:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_use_brand:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_use_brand:::--profile) :; return ;;
    quarto_add:::--embed) :; return ;;
    quarto_add:::--log) _quarto_files ""; return ;;
    quarto_add:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_add:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_add:::--profile) :; return ;;
    quarto_update:::--embed) :; return ;;
    quarto_update:::--log) _quarto_files ""; return ;;
    quarto_update:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_update:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_update:::--profile) :; return ;;
    quarto_remove:::--embed) :; return ;;
    quarto_remove:::--log) _quarto_files ""; return ;;
    quarto_remove:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_remove:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_remove:::--profile) :; return ;;
    quarto_convert:::-o|quarto_convert:::--output) _quarto_files ""; return ;;
    quarto_convert:::--log) _quarto_files ""; return ;;
    quarto_convert:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_convert:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_convert:::--profile) :; return ;;
    quarto_run:::--log) _quarto_files ""; return ;;
    quarto_run:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_run:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_run:::--profile) :; return ;;
    quarto_list:::--log) _quarto_files ""; return ;;
    quarto_list:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_list:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_list:::--profile) :; return ;;
    quarto_install:::--log) _quarto_files ""; return ;;
    quarto_install:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_install:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_install:::--profile) :; return ;;
    quarto_uninstall:::--log) _quarto_files ""; return ;;
    quarto_uninstall:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_uninstall:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_uninstall:::--profile) :; return ;;
    quarto_publish:::--id) :; return ;;
    quarto_publish:::--server) :; return ;;
    quarto_publish:::--token) :; return ;;
    quarto_publish:::--log) _quarto_files ""; return ;;
    quarto_publish:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_publish:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_publish:::--profile) :; return ;;
    quarto_check:::--output) _quarto_files ""; return ;;
    quarto_check:::--log) _quarto_files ""; return ;;
    quarto_check:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_check:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_check:::--profile) :; return ;;
    quarto_call_engine:::--log) _quarto_files ""; return ;;
    quarto_call_engine:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_call_engine:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_call_build_ts_extension:::--log) _quarto_files ""; return ;;
    quarto_call_build_ts_extension:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_call_build_ts_extension:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_call_typst_gather:::--log) _quarto_files ""; return ;;
    quarto_call_typst_gather:::--log-level) _quarto_words "debug info warning error critical"; return ;;
    quarto_call_typst_gather:::--log-format) _quarto_words "plain json-stream"; return ;;
    quarto_call_typst_gather:::--profile) :; return ;;
  esac

  if [[ "$cur" == -* ]]; then
    case "$cmd" in
      quarto) _quarto_words "-h --help -V --version"; return ;;
      quarto_render) _quarto_words "-h --help -t --to -o --output --output-dir -M --metadata --site-url --execute -P --execute-param --execute-params --execute-dir --execute-daemon --execute-daemon-restart --execute-debug --use-freezer --cache --cache-refresh --no-clean --debug --log --log-level --log-format --quiet --profile --no-execute --no-cache --toc --toc-depth --number-sections --number-offset --top-level-division --standalone --template --css --bibliography --csl --citeproc --highlight-style --pdf-engine --mathjax --katex --wrap --reference-doc --shift-heading-level-by"; return ;;
      quarto_preview) _quarto_words "-h --help --port --host --render --no-serve --no-navigate --no-browser --no-watch-inputs --timeout --log --log-level --log-format --quiet --profile --toc --toc-depth --number-sections --number-offset --top-level-division --standalone --template --css --bibliography --csl --citeproc --highlight-style --pdf-engine --mathjax --katex --wrap --reference-doc --shift-heading-level-by"; return ;;
      quarto_serve) _quarto_words "-h --help --no-render -p --port --host --browser --log --log-level --log-format --quiet --profile"; return ;;
      quarto_create) _quarto_words "-h --help --open --no-open --no-prompt --log --log-level --log-format --quiet --profile"; return ;;
      quarto_use) _quarto_words "-h --help --no-prompt"; return ;;
      quarto_use_template) _quarto_words "-h --help --no-prompt --log --log-level --log-format --quiet"; return ;;
      quarto_use_binder) _quarto_words "-h --help --no-prompt --log --log-level --log-format --quiet"; return ;;
      quarto_use_brand) _quarto_words "-h --help --force --dry-run --log --log-level --log-format --quiet --profile"; return ;;
      quarto_add) _quarto_words "-h --help --no-prompt --embed --log --log-level --log-format --quiet --profile"; return ;;
      quarto_update) _quarto_words "-h --help --no-prompt --embed --log --log-level --log-format --quiet --profile"; return ;;
      quarto_remove) _quarto_words "-h --help --no-prompt --embed --log --log-level --log-format --quiet --profile"; return ;;
      quarto_convert) _quarto_words "-h --help -o --output --with-ids --log --log-level --log-format --quiet --profile"; return ;;
      quarto_pandoc) _quarto_words ""; return ;;
      quarto_typst) _quarto_words ""; return ;;
      quarto_run) _quarto_words "-h --help --log --log-level --log-format --quiet --profile"; return ;;
      quarto_list) _quarto_words "-h --help --log --log-level --log-format --quiet --profile"; return ;;
      quarto_install) _quarto_words "-h --help --no-prompt --update-path --log --log-level --log-format --quiet --profile"; return ;;
      quarto_uninstall) _quarto_words "-h --help --no-prompt --update-path --log --log-level --log-format --quiet --profile"; return ;;
      quarto_tools) _quarto_words "-h --help"; return ;;
      quarto_publish) _quarto_words "-h --help --id --server --token --no-render --no-prompt --no-browser --log --log-level --log-format --quiet --profile"; return ;;
      quarto_check) _quarto_words "-h --help --output --no-strict --log --log-level --log-format --quiet --profile"; return ;;
      quarto_call) _quarto_words "-h --help"; return ;;
      quarto_call_engine) _quarto_words "-h --help --log --log-level --log-format --quiet"; return ;;
      quarto_call_build_ts_extension) _quarto_words "-h --help --check --init-config --log --log-level --log-format --quiet"; return ;;
      quarto_call_typst_gather) _quarto_words "-h --help --init-config --log --log-level --log-format --quiet --profile"; return ;;
    esac
    return
  fi

  if [ "$pos" = "0" ]; then
    case "$cmd" in
      quarto) _quarto_words "render preview serve create use add update remove convert pandoc typst run list install uninstall tools publish check call" ;;
      quarto_use) _quarto_words "template binder brand" ;;
      quarto_call) _quarto_words "engine build-ts-extension typst-gather" ;;
    esac
  fi

  case "${cmd}:::${pos}" in
    quarto_render:::0) _quarto_files "qmd|ipynb|md|Rmd|rmd|markdown"; return ;;
    quarto_render:::1) :; return ;;
    quarto_render:::2|quarto_render:::[0-9]*) :; return ;;
    quarto_preview:::0) _quarto_files "qmd|ipynb|md|Rmd|rmd|markdown"; return ;;
    quarto_preview:::1|quarto_preview:::[0-9]*) :; return ;;
    quarto_serve:::0) _quarto_files "qmd|ipynb|md|Rmd|rmd|markdown"; return ;;
    quarto_create:::0) _quarto_words "project extension"; return ;;
    quarto_create:::1|quarto_create:::[0-9]*) :; return ;;
    quarto_use:::0) :; return ;;
    quarto_use:::1) :; return ;;
    quarto_use_template:::0) :; return ;;
    quarto_use_brand:::0) :; return ;;
    quarto_add:::0) :; return ;;
    quarto_update:::0|quarto_update:::[0-9]*) _quarto_words "tinytex chrome-headless-shell verapdf"; return ;;
    quarto_remove:::0|quarto_remove:::[0-9]*) :; return ;;
    quarto_convert:::0) _quarto_files "qmd|ipynb|md|Rmd|rmd|markdown"; return ;;
    quarto_run:::0) _quarto_files "ts|js|py|R|r|lua"; return ;;
    quarto_run:::1|quarto_run:::[0-9]*) :; return ;;
    quarto_list:::0) _quarto_words "extensions tools"; return ;;
    quarto_install:::0|quarto_install:::[0-9]*) _quarto_words "tinytex chrome-headless-shell verapdf"; return ;;
    quarto_uninstall:::0) _quarto_words "tinytex chrome-headless-shell verapdf"; return ;;
    quarto_publish:::0) _quarto_words "quarto-pub gh-pages connect posit-connect-cloud netlify confluence huggingface"; return ;;
    quarto_publish:::1) _quarto_files "qmd|ipynb|md|Rmd|rmd|markdown"; return ;;
    quarto_check:::0) _quarto_words "install jupyter knitr versions all"; return ;;
    quarto_call_engine:::0) _quarto_words "jupyter knitr markdown julia"; return ;;
    quarto_call_engine:::1|quarto_call_engine:::[0-9]*) :; return ;;
    quarto_call_build_ts_extension:::0) _quarto_files "ts"; return ;;
  esac
}

complete -o bashdefault -o default -F _quarto quarto
