@echo off
title Desktop Pet AI - Uninstaller
color 0C

echo.
echo  ================================================
echo    Desktop Pet AI - Uninstaller
echo  ================================================
echo.
echo  This will completely remove Desktop Pet AI from
echo  your PC, including all saved data, reminders,
echo  chat history, and settings.
echo.
echo  Press CTRL+C at any time to cancel.
echo.
pause

echo.
echo  [1/4] Stopping Desktop Pet if it is running...
taskkill /IM desktop_pet.exe /F >nul 2>&1
timeout /t 2 /nobreak >nul

echo  [2/4] Removing saved app data (settings, reminders, chat)...
set "APPDATA_PATH=%USERPROFILE%\Documents"
if exist "%APPDATA_PATH%\default.isar" (
    del /f /q "%APPDATA_PATH%\default.isar" >nul 2>&1
    echo      Removed: Isar database
)
if exist "%APPDATA_PATH%\default.isar.lock" (
    del /f /q "%APPDATA_PATH%\default.isar.lock" >nul 2>&1
)

echo  [3/4] Removing Windows startup entry (if any)...
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "Desktop Pet" /f >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /v "desktop_pet" /f >nul 2>&1

echo  [4/4] Removing Windows Credential/DPAPI-stored API key...
powershell -Command "try { [Windows.Security.Credentials.PasswordVault, Windows.Security.Credentials, ContentType=WindowsRuntime]; $vault = New-Object Windows.Security.Credentials.PasswordVault; $vault.FindAllByResource('flutter_secure_storage') | ForEach-Object { $vault.Remove($_) } } catch { }" >nul 2>&1

echo.
echo  ================================================
echo   Done! Desktop Pet AI has been uninstalled.
echo.
echo   You can now safely delete this entire folder.
echo  ================================================
echo.
pause
