@echo off
title Claude Proxy Control
REM ASCII only. cmd.exe reads a .bat in the console OEM codepage, so UTF-8
REM Cyrillic in this file gets parsed as commands and the launcher dies with
REM "'E' is not recognized as an internal or external command".
REM Anything the user must read in Russian lives in README.txt or in the app.
set CPC_API_BASE=https://api.proxy.mindq.ru
REM Do not clobber a value that is already set - the rest of the runtime honours
REM CLAUDE_PROXY_HOME too, and it is the only way to test a build without
REM touching a real installation.
if not defined CLAUDE_PROXY_HOME set CLAUDE_PROXY_HOME=%USERPROFILE%\.claude-proxy-control
set APP=%~dp0
cd /d "%APP%"

REM Our own interpreter, shipped with the product. This used to look for a system
REM Python and end at "install Python 3.11+", which on a clean machine is where
REM the product stopped.
set CPC_PY=
if exist "%APP%..\python\pythonw.exe" set CPC_PY=%APP%..\python\pythonw.exe
if not defined CPC_PY if exist "%CLAUDE_PROXY_HOME%\python\pythonw.exe" set CPC_PY=%CLAUDE_PROXY_HOME%\python\pythonw.exe

if defined CPC_PY (
  start "" "%CPC_PY%" "%APP%claude_proxy_app.py"
  exit /b 0
)

REM Fallback: the machine's own interpreter. Only needed when running from source.
where pythonw >nul 2>&1 && (
  start "" pythonw "%APP%claude_proxy_app.py"
  exit /b 0
)
where python >nul 2>&1 && (
  python "%APP%claude_proxy_app.py"
  if errorlevel 1 pause
  exit /b %errorlevel%
)
echo Claude Proxy Control: interpreter not found.
echo The "python" folder must sit next to "desktop" - unpack the whole archive.
echo Podrobnee - README.txt
pause
exit /b 1
