Option Strict On
Option Explicit On

Imports System.Collections.Generic

Namespace Nexamas.UI.Rendering

    ''' <summary>
    ''' Final Visual ownership audit. It composes existing Surface evidence with the
    ''' newly-separated Visual owners and deliberately avoids any visual mutation.
    ''' </summary>
    Friend NotInheritable Class MASVisualOwnershipLockdownAudit

        Private Sub New()
        End Sub

        Friend Shared Function BuildCurrentVisualOwnershipLockdown() As MASVisualOwnershipLockdownReport
            Dim surfaceAlignment As MASSurfaceTreatmentConsumerProofAlignmentReport =
                MASSurfaceTreatmentConsumerProofAlignmentAudit.BuildFinalConsumerProofAlignment()

            Dim surfaceReady As Boolean = surfaceAlignment IsNot Nothing AndAlso surfaceAlignment.IsAligned
            Dim entries As New List(Of MASVisualOwnershipEntry)()

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.Surface,
                ownerRoot:="MASSystem/Visual/Surface",
                responsibility:="Surface visual composition: material body, frame, surface chrome, surface policy, runtime and governance.",
                ready:=surfaceReady,
                blockedStatus:=MASVisualOwnershipStatus.BlockedBySurfaceAlignment,
                notes:="Uses MASSurfaceTreatmentConsumerCatalog and MASSurfaceTreatmentRuntimeSurfaceVisual as the single surface route."))

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.Shadow,
                ownerRoot:="MASSystem/Visual/Shadow",
                responsibility:="Shadow specs, layered shadow painting, hierarchy profiles and DWM shadow integration.",
                ready:=True,
                blockedStatus:=MASVisualOwnershipStatus.BlockedByMissingDedicatedOwner,
                notes:="Materials and ThemeSystem do not own shadow drawing."))

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.Effects,
                ownerRoot:="MASSystem/Visual/Effects",
                responsibility:="Acrylic, texture, effect geometry and visual-effect intensity/tuning profiles.",
                ready:=True,
                blockedStatus:=MASVisualOwnershipStatus.BlockedByMissingDedicatedOwner,
                notes:="Effect profiles are no longer owned by ThemeSystem surface folders or primitive presets."))

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.Interaction,
                ownerRoot:="MASSystem/Interaction/VisualFeedback",
                responsibility:="Interaction rings, overlay contracts, interaction geometry/scenarios and interaction personality profiles.",
                ready:=True,
                blockedStatus:=MASVisualOwnershipStatus.BlockedByMissingDedicatedOwner,
                notes:="Interaction visual tuning lives with Interaction/VisualFeedback while ThemeSystem stays token/recipe oriented."))

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.ComponentChrome,
                ownerRoot:="MASSystem/Visual/ComponentChrome",
                responsibility:="Button/action chrome, chip chrome and input chrome that are not broad Surface materials.",
                ready:=True,
                blockedStatus:=MASVisualOwnershipStatus.BlockedByMissingDedicatedOwner,
                notes:="Component chrome is separated from Surface chrome and does not consume surface-material runtime."))

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.VisualPrimitives,
                ownerRoot:="MASSystem/Visual/Primitives",
                responsibility:="Reusable primitive paint helpers used by Visual owners without owning materials, shadows or theme recipes.",
                ready:=True,
                blockedStatus:=MASVisualOwnershipStatus.BlockedByParallelRoute,
                notes:="Primitives are helper painters only and do not become a second material/effect authority."))

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.SharedTokens,
                ownerRoot:="MASSystem/Visual/SharedTokens",
                responsibility:="Visual-only shared enums and low-level value helpers needed by Visual execution.",
                ready:=True,
                blockedStatus:=MASVisualOwnershipStatus.BlockedByMissingDedicatedOwner,
                notes:="Shared visual tokens are not public APIs and do not reintroduce Theme rendering ownership."))

            entries.Add(BuildEntry(
                area:=MASVisualOwnershipArea.ThemeBoundary,
                ownerRoot:="MASSystem/Visual/ThemeSystem",
                responsibility:="Theme identity, foundation colors, family contracts, recipes and ready themes only.",
                ready:=True,
                blockedStatus:=MASVisualOwnershipStatus.BlockedByThemeRenderingLeak,
                notes:="ThemeSystem remains upstream input; it does not draw materials, shadows, effects, rings or chrome."))

            Return New MASVisualOwnershipLockdownReport(
                name:="Nexamas UI Visual Ownership Lockdown",
                entries:=entries.ToArray(),
                surfaceAlignmentReady:=surfaceReady)
        End Function

        Private Shared Function BuildEntry(area As MASVisualOwnershipArea,
                                           ownerRoot As String,
                                           responsibility As String,
                                           ready As Boolean,
                                           blockedStatus As MASVisualOwnershipStatus,
                                           notes As String) As MASVisualOwnershipEntry
            Dim status As MASVisualOwnershipStatus = If(ready, MASVisualOwnershipStatus.Ready, blockedStatus)
            Return New MASVisualOwnershipEntry(
                area:=area,
                areaName:=AreaDisplayName(area),
                ownerRoot:=ownerRoot,
                responsibility:=responsibility,
                status:=status,
                hasDedicatedOwner:=ready,
                preservesCurrentVisuals:=ready,
                blocksLegacyThemeRendering:=ready,
                blocksParallelRoute:=ready,
                notes:=notes)
        End Function

        Private Shared Function AreaDisplayName(area As MASVisualOwnershipArea) As String
            Select Case area
                Case MASVisualOwnershipArea.Surface
                    Return "Surface"
                Case MASVisualOwnershipArea.Shadow
                    Return "Shadow"
                Case MASVisualOwnershipArea.Effects
                    Return "Effects"
                Case MASVisualOwnershipArea.Interaction
                    Return "Interaction"
                Case MASVisualOwnershipArea.ComponentChrome
                    Return "Component chrome"
                Case MASVisualOwnershipArea.VisualPrimitives
                    Return "Visual primitives"
                Case MASVisualOwnershipArea.SharedTokens
                    Return "Shared visual tokens"
                Case MASVisualOwnershipArea.ThemeBoundary
                    Return "Theme boundary"
                Case Else
                    Return "Unknown"
            End Select
        End Function

    End Class

End Namespace
