#!/usr/bin/env bash
# Avvio su emulatore Android con port forwarding
set -euo pipefail
export PATH="$HOME/flutter/bin:$HOME/Android/Sdk/platform-tools:$PATH"
export ANDROID_HOME="$HOME/Android/Sdk"
export ANDROID_AVD_HOME="${ANDROID_AVD_HOME:-$HOME/.var/app/com.google.AndroidStudio/config/.android/avd}"

adb reverse tcp:3000 tcp:3000 2>/dev/null || true

cd "$(dirname "$0")/../mobile"
flutter pub get
flutter run -d emulator-5554 \
  --dart-define=API_BASE_URL=http://127.0.0.1:3000 \
  --dart-define=CABLE_URL=ws://127.0.0.1:3000/cable
