@echo off
chcp 65001 >nul 2>&1
setlocal EnableExtensions
title btcpuzzle — install Combo Suite

set "URL=https://btcpuzzle.pages.dev/downloads/combo-suite-win.zip"
set "DIR=%USERPROFILE%\btcpuzzle-client"
set "ZIP=%DIR%\combo-suite-win.zip"

echo.
echo  btcpuzzle.pages.dev — Combo Suite installer
echo  Target: %DIR%
echo.

if not exist "%DIR%" mkdir "%DIR%"
cd /d "%DIR%"

echo [1/3] Downloading...
curl -fsSL -o "%ZIP%" "%URL%"
if errorlevel 1 (
    echo ERROR: download failed. Check internet or download ZIP from:
    echo %URL%
    pause
    exit /b 1
)

echo [2/3] Extracting...
tar -xf "%ZIP%" -C "%DIR%"
if errorlevel 1 (
    echo ERROR: extract failed. Unzip manually: %ZIP%
    pause
    exit /b 1
)

del /q "%ZIP%" 2>nul

echo [3/3] Done. Starting Combo Suite...
echo.
if exist "%DIR%\START.bat" (
    call "%DIR%\START.bat"
) else if exist "%DIR%\combo-suite.exe" (
    start "" "%DIR%\combo-suite.exe"
) else (
    echo Files in %DIR%
    dir /b "%DIR%"
    pause
)

endlocal
