#!/bin/bash
set -e
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
APP_SRC="$SCRIPT_DIR/BEANalyzer UltraPro.app"
APP_DST="/Applications/BEANalyzer UltraPro.app"

if [ ! -d "$APP_SRC" ]; then
    osascript -e 'display dialog "BEANalyzer UltraPro.app was not found next to this installer." buttons {"OK"} default button "OK" with icon caution'
    exit 1
fi

echo "Installing BEANalyzer UltraPro to /Applications..."
rm -rf "$APP_DST"
cp -R "$APP_SRC" "/Applications/"

chmod +x "$APP_DST/Contents/MacOS/BEANalyzerUltraPro"
xattr -dr com.apple.quarantine "$APP_DST" 2>/dev/null || true

osascript -e 'display dialog "BEANalyzer UltraPro has been copied to /Applications.\n\nYou can now open it from Applications, Launchpad, Dock, or Spotlight." buttons {"OK"} default button "OK" with icon note'
