@echo off
REM ===================================================================
REM  Website Wizz Pro - one-click PC setup
REM
REM  Double-click this file. That is the whole thing.
REM
REM  It asks for admin, downloads everything from the MacBook, and runs
REM  the install. Nothing to type.
REM ===================================================================

REM Windows will not let a normal window create scheduled tasks, so if
REM this was not started as admin it relaunches itself elevated and the
REM first copy exits.
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo Asking for administrator access...
    powershell -Command "Start-Process '%~f0' -Verb RunAs"
    exit /b
)

title Website Wizz Pro - PC Setup
color 0A

set SRC=http://192.168.40.38:8000
set DEST=%USERPROFILE%\wizz-setup

echo.
echo  ================================================
echo   WEBSITE WIZZ PRO - PC SETUP
echo  ================================================
echo.
echo   This takes about 10 minutes. You can walk away.
echo.

if not exist "%DEST%" mkdir "%DEST%"
cd /d "%DEST%"

echo  [1/3] Downloading. The big one is 300MB, be patient.
echo.

for %%F in (1-code.tar.gz 2-claude.tar.gz windows-setup.ps1 wizos-requirements.txt STOP-MAC.sh) do (
    echo        %%F
    curl.exe -# -o "%%F" "%SRC%/%%F"
    if errorlevel 1 (
        echo.
        echo  ERROR: could not download %%F
        echo.
        echo  The MacBook is either off, asleep, or on a different wifi
        echo  than this PC. Both have to be on the same network.
        echo.
        pause
        exit /b 1
    )
)

echo.
echo  [2/3] Checking the downloads are complete.

REM A half-finished download produces a file that exists but is tiny,
REM which fails later in a confusing way. Better to catch it here.
for %%F in (1-code.tar.gz 2-claude.tar.gz) do (
    for %%S in ("%%F") do if %%~zS LSS 1000000 (
        echo.
        echo  ERROR: %%F only downloaded partially.
        echo  Run this file again.
        echo.
        pause
        exit /b 1
    )
)
echo        looks good.

echo.
echo  [3/3] Installing. This is the long part.
echo.

powershell -NoProfile -ExecutionPolicy Bypass -File "%DEST%\windows-setup.ps1"

echo.
echo  ================================================
echo   DONE
echo  ================================================
echo.
echo   Now text your bot on Telegram.
echo   If it answers, everything worked.
echo.
echo   Then tell Claude on your phone, so the old Mac
echo   gets shut off. Do not skip that part.
echo.
pause
