Option Strict On
Option Explicit On

Imports System.Collections.Generic

Namespace Nexamas.UI.Rendering

    ''' <summary>
    ''' Source-level report proving that Surface Designer sees the same material/profile/slot
    ''' system that runtime surfaces use. It carries counts only and never exposes registries.
    ''' </summary>
    Friend NotInheritable Class MASSurfaceMaterialDesignerIntegrationReport
        Private ReadOnly _statuses As IReadOnlyList(Of MASSurfaceMaterialDesignerIntegrationStatus)

        Friend Sub New(materialCount As Integer,
                       materialProfileCount As Integer,
                       slotCount As Integer,
                       assignmentCount As Integer,
                       nativeProfileCount As Integer,
                       statuses As IEnumerable(Of MASSurfaceMaterialDesignerIntegrationStatus),
                       notes As String)
            Me.MaterialCount = Math.Max(0, materialCount)
            Me.MaterialProfileCount = Math.Max(0, materialProfileCount)
            Me.SlotCount = Math.Max(0, slotCount)
            Me.AssignmentCount = Math.Max(0, assignmentCount)
            Me.NativeProfileCount = Math.Max(0, nativeProfileCount)
            _statuses = CopyStatuses(statuses)
            Me.Notes = Normalize(notes)
        End Sub

        Friend ReadOnly Property MaterialCount As Integer
        Friend ReadOnly Property MaterialProfileCount As Integer
        Friend ReadOnly Property SlotCount As Integer
        Friend ReadOnly Property AssignmentCount As Integer
        Friend ReadOnly Property NativeProfileCount As Integer
        Friend ReadOnly Property Notes As String

        Friend ReadOnly Property Statuses As IReadOnlyList(Of MASSurfaceMaterialDesignerIntegrationStatus)
            Get
                Return _statuses
            End Get
        End Property

        Friend ReadOnly Property IsReady As Boolean
            Get
                Return Statuses.Count = 1 AndAlso Statuses(0) = MASSurfaceMaterialDesignerIntegrationStatus.Ready
            End Get
        End Property

        Private Shared Function CopyStatuses(items As IEnumerable(Of MASSurfaceMaterialDesignerIntegrationStatus)) As IReadOnlyList(Of MASSurfaceMaterialDesignerIntegrationStatus)
            Dim list As New List(Of MASSurfaceMaterialDesignerIntegrationStatus)()
            If items IsNot Nothing Then list.AddRange(items)
            If list.Count = 0 Then list.Add(MASSurfaceMaterialDesignerIntegrationStatus.Ready)
            Return list.AsReadOnly()
        End Function

        Private Shared Function Normalize(value As String) As String
            Return If(value, String.Empty).Trim()
        End Function

    End Class

End Namespace
