param(
    [string]$ConfigPath = "C:\Users\niuniu\.codex\vip-report\config.yaml",
    [string]$Slides = "S04,S05,S06,S07,S08",
    [string]$ReportMonth = "",
    [int]$ReportYear = 0,
    [int]$CompareYear = 0,
    [string]$OutputDir = "",
    [switch]$DisableTemplateLock
)

$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot
$resolvedOutputDir = if ($OutputDir) { [System.IO.Path]::GetFullPath($OutputDir) } else { "C:\workspace\cursor\output\vip-report" }
$opsPath = Join-Path $resolvedOutputDir "render-ops.inventory-monthly.live.json"

if (-not (Test-Path -LiteralPath $resolvedOutputDir)) {
    New-Item -ItemType Directory -Path $resolvedOutputDir -Force | Out-Null
}

$pythonArgs = @(
    "$root\scripts\sync_inventory_monthly_assets.py",
    "--config", "$ConfigPath",
    "--slides", "$Slides"
)
if ($ReportMonth) {
    $pythonArgs += @("--report-month", "$ReportMonth")
}
if ($ReportYear -gt 0) {
    $pythonArgs += @("--report-year", "$ReportYear")
}
if ($CompareYear -gt 0) {
    $pythonArgs += @("--compare-year", "$CompareYear")
}
if ($DisableTemplateLock.IsPresent) {
    $pythonArgs += "--disable-template-lock"
}
$pythonArgs += @("--output-dir", "$resolvedOutputDir")
python @pythonArgs

Write-Output $opsPath
