@echo off
chcp 65001 >nul
title Instalador Oficial - FV Plataformas
color 0C

echo ==========================================================
echo        INSTALADOR OFICIAL - FV PLATAFORMAS STREAMING
echo ==========================================================
echo.
echo [1/3] Configurando directorio de instalacion...
set "APP_DIR=%LOCALAPPDATA%\FVPlataformas"
if not exist "%APP_DIR%" mkdir "%APP_DIR%"

echo [2/3] Descargando la aplicacion oficial de FV Plataformas...
powershell -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; (New-Object System.Net.WebClient).DownloadFile('https://plataformas.fvstgroup.com/downloads/FV_Plataformas.exe', '%APP_DIR%\FV_Plataformas.exe')"

if not exist "%APP_DIR%\FV_Plataformas.exe" (
    echo.
    echo [ERROR] No se pudo descargar la aplicacion. Verifica tu conexion a internet.
    pause
    exit /b 1
)

echo [3/3] Creando acceso directo en el Escritorio...
powershell -Command "$WshShell = New-Object -ComObject WScript.Shell; $Shortcut = $WshShell.CreateShortcut([System.IO.Path]::Combine([Environment]::GetFolderPath('Desktop'), 'FV Plataformas.lnk')); $Shortcut.TargetPath = '%APP_DIR%\FV_Plataformas.exe'; $Shortcut.WorkingDirectory = '%APP_DIR%'; $Shortcut.IconLocation = '%APP_DIR%\FV_Plataformas.exe,0'; $Shortcut.Save()"

echo.
echo ==========================================================
echo        INSTALACION COMPLETADA CON EXITO!
echo ==========================================================
echo Iniciando FV Plataformas...
start "" "%APP_DIR%\FV_Plataformas.exe"
timeout /t 3 >nul
exit
