@echo off
chcp 65001 >nul
title CapCut Agent (Multi-Range)
cd /d "%~dp0"

echo.
echo   ============================================
echo    CapCut Agent - Multi-Range (v2)
echo   ============================================
echo.
echo   URL : http://127.0.0.1:8001
echo   - One URL + multiple time ranges, merged into one draft.
echo   - Browser opens automatically in a few seconds.
echo   - KEEP THIS WINDOW OPEN. Close it to stop the server.
echo.

REM Python 확인
where python >nul 2>nul
if errorlevel 1 (
  echo   [ERROR] python not found on PATH.
  echo   Install Python from python.org and re-run.
  echo.
  pause
  exit /b 1
)

REM 잠시 후 브라우저 열기(서버 뜬 다음). 분리 실행. (v1과 다른 포트 8001 → 동시 실행 가능)
start "" powershell -NoProfile -WindowStyle Hidden -Command "Start-Sleep 3; Start-Process 'http://127.0.0.1:8001'"

REM 서버를 이 창에서 실행(로그/에러가 보임)
python -m uvicorn server.app:app --port 8001

echo.
echo   ============================================
echo    Server stopped.
echo   ============================================
echo   (If it failed instantly, read the error above.)
echo.
pause
