# Capture MariBank SG hook logs (clears buffer first if -Clear switch passed)
param([switch]$Clear)
$adb = "C:\Users\Administrator\AppData\Local\Android\Sdk\platform-tools\adb.exe"
if (-not (Test-Path $adb)) {
    Write-Host "adb not found: $adb" -ForegroundColor Red
    exit 1
}
if ($Clear) {
    & $adb logcat -c
    Write-Host "Logcat cleared. Now click Next in MariBank, then run without -Clear:" -ForegroundColor Yellow
    Write-Host "  .\scripts\logcat-maribank.ps1"
    exit 0
}
& $adb logcat -d 2>&1 | Select-String -Pattern "MariBankRoot|MariBankNative" |
    Select-String -Pattern "HTTP|outbound|register|faked|finish adb|blocked|ErrorFlow|RegisterViewModel|skip error|late app|late native|assessRisk|risk callback"
