[CmdletBinding()]
param(
  [Parameter(Mandatory)] [string]$RuntimeDirectory
)

$ErrorActionPreference = 'Stop'
$root = (Resolve-Path -LiteralPath $RuntimeDirectory).Path
$required = @(
  'avcodec-63.dll'
  'avdevice-63.dll'
  'avfilter-12.dll'
  'avformat-63.dll'
  'avutil-61.dll'
  'swresample-7.dll'
  'swscale-10.dll'
  'libx264-165.dll'
  'libx265.dll'
  'dovi.dll'
  'libplacebo-349.dll'
  'libvpl-2.dll'
)
$missing = @($required | Where-Object { -not (Test-Path -LiteralPath (Join-Path $root $_)) })
if ($missing.Count -gt 0) {
  Write-Error "Runtime dependency set is incomplete: $($missing -join ', ')"
  exit 2
}
$allowed = [System.Collections.Generic.HashSet[string]]::new([StringComparer]::OrdinalIgnoreCase)
foreach ($name in $required) { [void]$allowed.Add($name) }
$unexpected = @(Get-ChildItem -LiteralPath $root -Filter '*.dll' | Where-Object { -not $allowed.Contains($_.Name) })
if ($unexpected.Count -gt 0) {
  Write-Error "Runtime contains unexpected DLLs: $($unexpected.Name -join ', ')"
  exit 3
}
Write-Output "Runtime dependency set accepted: $root"
