# shellcheck shell=bash

build_check_dependencies() {
  build_info "Checking dependencies..."

  if ! command -v cargo >/dev/null 2>&1; then
    build_error "Rust/Cargo not found. Please install Rust: https://rustup.rs/"
    exit 1
  fi

  if ! command -v cc >/dev/null 2>&1 && \
     ! command -v clang >/dev/null 2>&1 && \
     ! command -v gcc >/dev/null 2>&1; then
    build_error "C compiler not found. Bundled SQLite requires a native C toolchain."
    build_error "  macOS: xcode-select --install"
    build_error "  Ubuntu/Debian: sudo apt install build-essential"
    build_error "  RHEL/CentOS: sudo yum groupinstall 'Development Tools'"
    exit 1
  fi

  if ! command -v jq >/dev/null 2>&1; then
    build_warn "jq not found. Installing via package manager is recommended."
    build_warn "  macOS: brew install jq"
    build_warn "  Ubuntu/Debian: sudo apt install jq"
    build_warn "  RHEL/CentOS: sudo yum install jq"
  fi

  if ! command -v tty >/dev/null 2>&1; then
    build_warn "tty command not found. Terminal title updates will be skipped."
  fi

  build_success "Dependencies check passed"
}
