#!/usr/bin/env bash
# spoof26 installer — curl -fsSL https://spoof26.pages.dev/install.sh | sh
set -euo pipefail

DIST_URL="https://spoof26.pages.dev/dist/spoof26-0.1.0.tar.gz"

info()  { printf '  \033[1;36m%s\033[0m %s\n' "$1" "$2"; }
err()   { printf '  \033[1;31merror:\033[0m %s\n' "$1" >&2; exit 1; }

info "spoof26" "installer"
echo ""

[[ "$(uname)" == "Darwin" ]] || err "spoof26 only supports macOS"

# Install uv if missing
if ! command -v uv &>/dev/null; then
    info "uv" "installing…"
    curl -LsSf https://astral.sh/uv/install.sh | sh
    export PATH="$HOME/.local/bin:$PATH"
fi
info "uv" "$(uv --version)"

# One command: fetches Python 3.13, creates isolated venv, installs from tarball
info "install" "spoof26 + pymobiledevice3 (this may take a moment)…"
uv tool install --force --python 3.13 "spoof26 @ $DIST_URL"

echo ""
info "done!" "run with: sudo spoof26"
echo ""
echo "  Usage:"
echo "    sudo spoof26                    # launch the spoofer"
echo "    sudo spoof26 --enable-dev-mode  # enable Developer Mode (first time)"
echo "    sudo spoof26 --uninstall        # remove spoof26"
echo ""
