@echo off
cd /d "%~dp0desktop-client"

echo ==========================================================
echo Amethyst Cloud Storage - Desktop Client Starting
echo ==========================================================

where node >nul 2>nul
if %ERRORLEVEL% neq 0 (
    echo [ERROR] Node.js not found! Please install Node.js from https://nodejs.org/
    pause
    exit /b 1
)

if not exist "node_modules\electron" (
    echo [Amethyst Desktop] Installing dependencies...
    call npm install
)

set "TARGET_URL=%~1"
if "%TARGET_URL%"=="" (
    set "TARGET_URL=http://localhost/"
)

set "AMETHYST_SERVER_URL=%TARGET_URL%"
echo [Amethyst Desktop] Target URL: %AMETHYST_SERVER_URL%
echo [Amethyst Desktop] Launching Electron app...

call npx electron .
