@echo off
setlocal
title ScoreToMML Local Launcher

set "SCRIPT_URL=https://raw.githubusercontent.com/COCOnuttooo/score_to_mml_hf/main/static/downloads/score-to-mml-local-install.ps1"
set "SCRIPT_PATH=%TEMP%\score-to-mml-local-install.ps1"

echo ScoreToMML Local Launcher
echo -------------------------
echo Downloading installer...

powershell -NoProfile -ExecutionPolicy Bypass -Command "Invoke-WebRequest -Uri '%SCRIPT_URL%' -OutFile '%SCRIPT_PATH%'"
if errorlevel 1 (
  echo Failed to download installer.
  pause
  exit /b 1
)

powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_PATH%"
set "EXIT_CODE=%ERRORLEVEL%"
del "%SCRIPT_PATH%" >nul 2>nul

if not "%EXIT_CODE%"=="0" (
  echo.
  echo Installation failed. See the message above.
  pause
  exit /b %EXIT_CODE%
)

echo.
echo Setup complete.
pause
