@echo off
title Kling Token Bot Local Server & Cloudflare Bypass
echo ==========================================================
echo   MEMULAI BOT KLING MOTION (LOCALHOST SERVER + BYPASS)
echo ==========================================================
echo.

:: 1. Cek / install node_modules
if not exist node_modules (
    echo [INFO] Folder node_modules tidak ditemukan.
    echo Menginstal dependensi server utama...
    echo.
    call npm install
    if errorlevel 1 (
        echo [ERROR] Gagal menginstal dependensi server!
        pause
        exit /b 1
    )
)

:: 2. Cek / install node_modules di folder cloudflare
if not exist cloudflare\node_modules (
    echo [INFO] Folder node_modules di folder cloudflare tidak ditemukan.
    echo Menginstal dependensi cloudflare bypass...
    echo.
    cd cloudflare
    call npm install
    cd ..
    if errorlevel 1 (
        echo [ERROR] Gagal menginstal dependensi cloudflare!
        pause
        exit /b 1
    )
)

echo.
echo [INFO] Menyalakan Cloudflare Auto-Bypass di jendela baru...
start cmd /k "title Cloudflare Auto-Bypass Daemon && cd cloudflare && node auto-bypass.js"

echo [INFO] Menyalakan Localhost Server...
node server.js

pause
