@echo off
title IceApp Bridge
set "DIR=%LOCALAPPDATA%\IceAppBridge"
set "SCRIPT=%DIR%\iceapp-bridge.mjs"
mkdir "%DIR%" 2>nul
where node >nul 2>&1 || (
  echo Instaleaza Node.js: https://nodejs.org
  pause
  exit /b 1
)
echo Descarc bridge...
powershell -NoProfile -ExecutionPolicy Bypass -Command ^
  "Invoke-WebRequest -Uri 'https://iceappl.duckdns.org/api/bridge/script' -OutFile '%SCRIPT%' -UseBasicParsing"
if not exist "%SCRIPT%" (
  echo Descarcare esuata.
  pause
  exit /b 1
)
echo Pornesc bridge...
start "IceApp Bridge" /min node "%SCRIPT%"
timeout /t 2 /nobreak >nul
start http://127.0.0.1:19766/
echo Bridge activ. Inchide fereastra — ruleaza in fundal.
echo In IceApp: Preview - Pornește tunel
timeout /s 5
