@echo off
setlocal
echo ============================================
echo   NotifyPulse V3 - Build
echo ============================================
echo.

where python >nul 2>&1
if errorlevel 1 (
    echo ERROR: Python not found in PATH
    pause & exit /b 1
)

echo [1/3] Installing dependencies...
pip install -r requirements.txt --quiet
if errorlevel 1 ( echo FAILED & pause & exit /b 1 )

echo [2/3] Generating icon...
python make_ico.py
if errorlevel 1 ( echo WARNING: icon generation failed, using default )

echo [3/3] Building executable...
pyinstaller --noconfirm --onefile --windowed ^
  --name "NotifyPulse-V3" ^
  --icon "%APPDATA%\NotifyPulse\icon.ico" ^
  --add-data "ui;ui" ^
  --add-data "pwa;pwa" ^
  --hidden-import=winotify ^
  --hidden-import=pystray ^
  --hidden-import=PIL ^
  --hidden-import=schedule ^
  --hidden-import=keyboard ^
  --hidden-import=flask ^
  --hidden-import=flask_cors ^
  notifier.py

if errorlevel 1 (
    echo BUILD FAILED
    pause & exit /b 1
)

echo.
echo ============================================
echo   SUCCESS: dist\NotifyPulse-V3.exe
echo ============================================
echo.
echo Place the exe alongside the ui\ and pwa\ folders.
echo Or run with: python notifier.py
pause
