@echo off
REM Build and export theme-2 player theme only.
REM Automatically switches to 'theme-2' branch, builds, and restores original branch.
REM Usage: docs\docker\build-and-export-player-theme-2.bat [options]

cd /d "%~dp0..\.."
set "BRANCH=theme-2"
set "TAG=theme-2"

set "ORIGINAL_BRANCH="
for /f "delims=" %%B in ('git rev-parse --abbrev-ref HEAD 2^>nul') do set "ORIGINAL_BRANCH=%%B"
if not defined ORIGINAL_BRANCH (
  echo ERROR: Cannot determine current Git branch.
  exit /b 1
)

echo [INFO] Switching to branch %BRANCH%...
git checkout %BRANCH% >nul 2>&1
if errorlevel 1 (
  echo [ERROR] Cannot switch to branch %BRANCH%
  exit /b 1
)

call docs\docker\build-and-export-images.bat --service player --tag %TAG% %*
set "BUILD_STATUS=%ERRORLEVEL%"

echo [INFO] Restoring original branch: %ORIGINAL_BRANCH%
git checkout %ORIGINAL_BRANCH% >nul 2>&1

exit /b %BUILD_STATUS%
