#!/bin/sh
# Double-clickable TESI Connect launcher for macOS (.command)
# Verifies SHA-256 before running and opens the 1-click browser approval page.
set -eu
echo "=========================================="
echo "  TESI Connect — macOS 1-Click Setup"
echo "=========================================="
umask 077
INSTALLER_FILE="$(mktemp "${TMPDIR:-/tmp}/tesi-connect-launch.XXXXXXXX")"
trap 'rm -f "$INSTALLER_FILE"' EXIT
trap 'exit 1' HUP INT TERM
if curl -fsSL "https://toolsenabled.ai/connect/install.sh" -o "$INSTALLER_FILE" && [ -s "$INSTALLER_FILE" ]; then STATUS=0; sh "$INSTALLER_FILE" || STATUS=$?; else STATUS=$?; echo "TESI Connect could not download its installer." >&2; fi
echo ""
if [ "$STATUS" -eq 0 ]; then
  echo "TESI Connect setup complete. You may close this window."
else
  echo "TESI Connect setup exited with code $STATUS."
fi
printf "Press Enter to close..."
read _unused || true
exit "$STATUS"
