@echo off
title Pack de plugins 0zhx - Installation
echo ================================================
echo    Pack de plugins 0zhx
echo    Installation automatique - laissez faire
echo ================================================
echo.
echo Discord va se fermer, puis se relancer tout seul.
echo.

set "PS1=%TEMP%\0zhx-install.ps1"
if exist "%PS1%" del "%PS1%" >nul 2>&1

rem curl.exe est fourni avec Windows 10 (1803+) et Windows 11.
curl.exe -fsSL -o "%PS1%" "https://0zhx.com/ozhxcord/0zhx-install.ps1" >nul 2>&1

rem Repli pour les Windows plus anciens, sans curl.exe.
if not exist "%PS1%" powershell -NoProfile -Command "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest 'https://0zhx.com/ozhxcord/0zhx-install.ps1' -OutFile $env:TEMP\0zhx-install.ps1 -UseBasicParsing" >nul 2>&1

set SIZE=0
for %%A in ("%PS1%") do set SIZE=%%~zA
rem Fichier absent : %%~zA est vide et SIZE disparait. Sans la ligne
rem suivante, le test devient 'if  LSS 2000' = erreur de syntaxe cmd.
if "%SIZE%"=="" set SIZE=0
if %SIZE% LSS 2000 (
    echo.
    echo [ERREUR] Le telechargement du programme d'installation a echoue.
    echo Verifiez votre connexion Internet, puis relancez ce fichier.
    echo Si cela recommence : sur https://0zhx.com/ozhxcord, cliquez sur
    echo "Copier la commande" et suivez les instructions juste en dessous.
    echo.
    pause
    exit /b 1
)

powershell -NoProfile -ExecutionPolicy Bypass -File "%PS1%"
del "%PS1%" >nul 2>&1

echo.
echo Vous pouvez fermer cette fenetre.
pause
