Option Strict On
Option Explicit On

Imports System
Imports Nexamas.UI.Application
Imports Nexamas.UI.Components
Imports Nexamas.UI.Controls
Imports Nexamas.UI.Layout

Partial Friend Class NexamasUIShowcase

    Private _showcaseMainMenuBar As MASMenuBar

    Private Sub AttachShowcaseMainMenu()
        If Window Is Nothing Then Return

        ' Navigation discipline: the full-width menu owns only global discovery.
        ' It is attached once through the official shell-owned AddMenuBar gateway.
        ' It must not be added to PageHost content through page.FullWidth/Grid/Section,
        ' because MASMenuBar is application chrome rather than a page control.
        _showcaseMainMenuBar = Window.Controls.AddMenuBar(
            Sub(bar As MASMenuBar)
                bar.AddAction("Start", "Overview", HomePageId, Sub() Window.Pages.NavigateTo(HomePageId))

                ' Wizard-first navigation: all catalog capability routes are now represented
                ' inside focused guided journeys. The MASMenuBar must therefore stop
                ' exposing every capability as a second parallel page entry. Keep only
                ' global launch points plus compact area overviews for orientation.
                AddJourneyNavigationMenu(bar)
                AddAreaOverviewNavigationMenu(bar)
            End Sub)

        _showcaseMainMenuBar.WithSize(MASSize.FillWidth)
    End Sub

    Private Sub AddAreaOverviewNavigationMenu(bar As MASMenuBar)
        If bar Is Nothing Then Return

        For Each category As ShowcaseNavigationCategory In ShowcaseNavigationCatalog.GetCategories()
            Dim categoryForMenu As ShowcaseNavigationCategory = category
            bar.AddAction(
                "Areas",
                ShowcaseNavigationCatalog.ResolveCategoryTitle(categoryForMenu) & " overview",
                ShowcaseNavigationCatalog.ResolveCategoryPageId(categoryForMenu),
                Sub() Window.Pages.NavigateTo(ShowcaseNavigationCatalog.ResolveCategoryPageId(categoryForMenu)))
        Next
    End Sub

    Private Sub AddJourneyNavigationMenu(bar As MASMenuBar)
        If bar Is Nothing Then Return

        bar.AddAction("Journeys", "Controls exploration", GuidedJourneyPageId & ".controls.0", Sub() OpenGuidedJourney("controls", 0))
        bar.AddAction("Journeys", "Systems exploration", GuidedJourneyPageId & ".systems.0", Sub() OpenGuidedJourney("systems", 0))
        bar.AddAction("Journeys", "Data workspace exploration", GuidedJourneyPageId & ".data.0", Sub() OpenGuidedJourney("data", 0))
        bar.AddAction("Journeys", "Theme / RTL exploration", GuidedJourneyPageId & ".theme.0", Sub() OpenGuidedJourney("theme", 0))
        bar.AddAction("Journeys", "Quality proof journey", GuidedJourneyPageId & ".proof.0", Sub() OpenGuidedJourney("proof", 0))
    End Sub

End Class
