IntuneDiff.psm1

# Copyright (c) 2026 Sandy Zeng. All rights reserved.
# Source-available. All rights reserved. See LICENSE file.

# IntuneDiff PowerShell GUI module
# Dot-sources private and public function files at import time.

$ErrorActionPreference = 'Stop'

# Module-scoped state shared across all functions
$script:SignedInUser = $null
$script:CategoriesData = $null
$script:WhfbCategoriesData = $null
$script:VerboseMode = $false

function Write-IDLog {
    <# Module-wide verbose logger. Outputs timestamped messages when -Verbose is active. #>
    param([string]$Message)
    if ($script:VerboseMode) {
        $ts = Get-Date -Format 'HH:mm:ss'
        Write-Host "[$ts IntuneDiff] $Message" -ForegroundColor DarkGray
    }
}

# Discover and dot-source all .ps1 files under Private/ and Public/
$folders = @('Private/Auth', 'Private/Graph', 'Private/Logic', 'Private/UI', 'Public')
foreach ($folder in $folders) {
    $path = Join-Path -Path $PSScriptRoot -ChildPath $folder
    if (-not (Test-Path -LiteralPath $path)) { continue }
    Get-ChildItem -LiteralPath $path -Filter '*.ps1' -File | ForEach-Object {
        . $_.FullName
    }
}

Export-ModuleMember -Function 'Start-IntuneDiff'