<#
.SYNOPSIS
  Create first-run administrator if setup is still needed.
.EXAMPLE
  .\scripts\bootstrap-admin.ps1 -Email you@company.com -Password 'YourSecurePass123!'
#>
param(
    [Parameter(Mandatory)][string]$Email,
    [Parameter(Mandatory)][string]$Password,
    [string]$DisplayName = '',
    [string]$Api = 'http://localhost:3041'
)

$body = @{
    email       = $Email
    password    = $Password
    displayName = $DisplayName
} | ConvertTo-Json

$r = Invoke-RestMethod -Method POST -Uri "$Api/api/setup/bootstrap" -ContentType 'application/json' -Body $body
Write-Host "Administrator created: $($r.user.email)" -ForegroundColor Green
Write-Host "Sign in at http://localhost:3000/login"
