﻿Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic

''' <summary>
''' Single internal metadata catalog for the Nexamas UI Showcase product hub.
''' The Showcase remains a consumer: this catalog stores presentation metadata,
''' not controls, render policies, layout rules, theme logic, or platform evidence engines.
''' </summary>
Partial Friend NotInheritable Class ShowcaseNavigationCatalog

    Private Shared ReadOnly _categories As IReadOnlyList(Of ShowcaseNavigationCategory) = CreateCategories()
    Private Shared ReadOnly _entries As IReadOnlyList(Of ShowcaseNavigationEntry) = CreateEntries()
    Private Shared ReadOnly _entryKinds As IReadOnlyList(Of ShowcaseNavigationEntryKind) = CreateEntryKinds()

    Private Sub New()
    End Sub

    Friend Shared Function GetCategories() As IReadOnlyList(Of ShowcaseNavigationCategory)
        Return _categories
    End Function

    Friend Shared Function GetEntries() As IReadOnlyList(Of ShowcaseNavigationEntry)
        Return _entries
    End Function

    Friend Shared Function GetEntryKinds() As IReadOnlyList(Of ShowcaseNavigationEntryKind)
        Return _entryKinds
    End Function

    Friend Shared Function GetEntries(category As ShowcaseNavigationCategory) As IReadOnlyList(Of ShowcaseNavigationEntry)
        Dim result As New List(Of ShowcaseNavigationEntry)()

        For Each entry As ShowcaseNavigationEntry In _entries
            If entry IsNot Nothing AndAlso entry.Category = category Then
                result.Add(entry)
            End If
        Next

        Return result.AsReadOnly()
    End Function

    Friend Shared Function GetEntries(kind As ShowcaseNavigationEntryKind) As IReadOnlyList(Of ShowcaseNavigationEntry)
        Dim result As New List(Of ShowcaseNavigationEntry)()

        For Each entry As ShowcaseNavigationEntry In _entries
            If entry IsNot Nothing AndAlso ResolveEntryKind(entry) = kind Then
                result.Add(entry)
            End If
        Next

        Return result.AsReadOnly()
    End Function

    Friend Shared Function FindByCommandId(commandId As String) As ShowcaseNavigationEntry
        Dim normalizedCommandId As String = If(commandId, String.Empty).Trim()
        If normalizedCommandId.Length = 0 Then Return Nothing

        For Each entry As ShowcaseNavigationEntry In _entries
            If entry IsNot Nothing AndAlso String.Equals(entry.CommandId, normalizedCommandId, StringComparison.OrdinalIgnoreCase) Then
                Return entry
            End If
        Next

        Return Nothing
    End Function

    Friend Shared Function FindById(id As String) As ShowcaseNavigationEntry
        Dim normalizedId As String = If(id, String.Empty).Trim()
        If normalizedId.Length = 0 Then Return Nothing

        For Each entry As ShowcaseNavigationEntry In _entries
            If entry IsNot Nothing AndAlso String.Equals(entry.Id, normalizedId, StringComparison.OrdinalIgnoreCase) Then
                Return entry
            End If
        Next

        Return Nothing
    End Function
End Class

Friend Enum ShowcaseNavigationCategory
    Foundation
    Controls
    Data
    LayoutAndWorkflow
    ThemeAndLocalization
    Output
    Quality
End Enum

Friend Enum ShowcaseNavigationEntryKind
    Foundation
    LiveDemo
    ProductSystem
    Proof
End Enum

Friend Enum ShowcaseCapabilityClassification
    Stable
    Advanced
    Preview
    Evidence
    Compat
End Enum

Friend NotInheritable Class ShowcaseNavigationEntry

    Friend ReadOnly Property Id As String
    Friend ReadOnly Property Title As String
    Friend ReadOnly Property Summary As String
    Friend ReadOnly Property Category As ShowcaseNavigationCategory
    Friend ReadOnly Property Classification As ShowcaseCapabilityClassification

    Friend Sub New(id As String,
                   title As String,
                   summary As String,
                   category As ShowcaseNavigationCategory,
                   classification As ShowcaseCapabilityClassification)
        Me.Id = If(id, String.Empty).Trim()
        Me.Title = If(title, String.Empty).Trim()
        Me.Summary = If(summary, String.Empty).Trim()
        Me.Category = category
        Me.Classification = classification
    End Sub

    Friend ReadOnly Property CommandId As String
        Get
            Return "showcase.open." & Id
        End Get
    End Property
End Class
