﻿Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports Nexamas.UI.Application
Imports Nexamas.UI.Components
Imports Nexamas.UI.Controls
Imports Nexamas.UI.Layout
Imports Nexamas.UI.TextInput

Partial Friend Class NexamasUIShowcase

    Private Sub BuildHomePreviewStrip(page As MASApplicationLayoutPageBuilder)
        If page Is Nothing Then Return

        Dim previewTitle As MASLabel = CreateBody("Live preview strip")
        previewTitle.LabelVariant = MASLabelVariant.Heading
        AddShowcaseContent(page, previewTitle, MASSize.FillWidth)
        AddShowcaseContent(page, CreateMuted("This strip is composed only from Nexamas.UI controls. It gives the first screen a real product feel without adding any Showcase-owned controls, rendering, layout, or theme code."), MASSize.FillWidth)

        Dim grid As MASApplicationLayoutGridBuilder = page.Grid(3).Gap(MASLayoutSpacing.Large).EqualItemSize()
        grid.Add(CreateMetric("Controls", "Live", "Button + input + validation").WithTrend("Public controls", MASToastTone.Success), MASSize.FillWidth)
        grid.Add(CreateMetric("Data", "Proof", "MetricCard + tables").WithTrend("SDK surfaces", MASToastTone.Info), MASSize.FillWidth)
        grid.Add(CreateMetric("Quality", "Certified", "Verification / gates").WithTrend("Evidence area", MASToastTone.Success), MASSize.FillWidth)

        Dim controlsFlow As MASApplicationLayoutFlowBuilder = page.Flow().Gap(MASLayoutSpacing.Small).EqualItemWidth()
        Dim primary As MASButton = Window.Controls.AddButton("Primary action")
        primary.AsPrimary().WithSize(MASSize.[Default])
        controlsFlow.Add(primary, MASSize.[Default])

        Dim search As MASSearchTextBox = Window.Controls.AddSearchTextBox("theme")
        search.Placeholder = "Search capability"
        search.WithSize(MASSize.[Default])
        controlsFlow.Add(search, MASSize.[Default])

        Dim validation As MASValidationMessage = Window.Controls.AddValidationMessage("Layout, theme, and hit-testing stay Nexamas.UI-owned.", MASTextValidationState.Success)
        validation.WithSize(MASSize.FillWidth)
        controlsFlow.Add(validation, MASSize.FillWidth)
    End Sub

    Private Sub BuildAreaPreview(page As MASApplicationLayoutPageBuilder,
                                 category As ShowcaseNavigationCategory)
        If page Is Nothing Then Return

        Dim title As MASLabel = CreateBody("Product preview")
        title.LabelVariant = MASLabelVariant.Heading
        AddShowcaseContent(page, title, MASSize.FillWidth)
        AddShowcaseContent(page, CreateMuted("Preview content is assembled from existing Nexamas.UI controls and public layout builders. The Showcase only chooses sample data and routes."), MASSize.FillWidth)

        Select Case category
            Case ShowcaseNavigationCategory.Foundation
                BuildFoundationAreaPreview(page)
            Case ShowcaseNavigationCategory.Controls
                BuildControlsAreaPreview(page)
            Case ShowcaseNavigationCategory.Data
                BuildDataAreaPreview(page)
            Case ShowcaseNavigationCategory.LayoutAndWorkflow
                BuildLayoutWorkflowAreaPreview(page)
            Case ShowcaseNavigationCategory.ThemeAndLocalization
                BuildThemeLocalizationAreaPreview(page)
            Case ShowcaseNavigationCategory.Output
                BuildOutputAreaPreview(page)
            Case ShowcaseNavigationCategory.Quality
                BuildQualityAreaPreview(page)
            Case Else
                AddShowcaseContent(page, CreateMuted("No preview is registered for this product area."), MASSize.FillWidth)
        End Select
    End Sub

    Private Sub BuildFoundationAreaPreview(page As MASApplicationLayoutPageBuilder)
        Dim grid As MASApplicationLayoutGridBuilder = page.Grid(3).Gap(MASLayoutSpacing.Medium).EqualItemSize()
        grid.Add(CreateMetric("PageHost", "Owned", "MASApplicationWindow.Pages").WithTrend("Same-window route", MASToastTone.Success), MASSize.FillWidth)
        grid.Add(CreateMetric("Services", "Facade", "Dialogs / toasts / menus").WithTrend("Public Window.Services", MASToastTone.Info), MASSize.FillWidth)
        grid.Add(CreateMetric("Boundary", "Clean", "No internal imports").WithTrend("Consumer-safe", MASToastTone.Success), MASSize.FillWidth)

        AddShowcaseContent(page, CreateMuted("Open the concrete Foundation pages from the full-width MASMenuBar, guided journeys, or capability discovery matrix."), MASSize.FillWidth)
    End Sub

    Private Sub BuildControlsAreaPreview(page As MASApplicationLayoutPageBuilder)
        Dim flow As MASApplicationLayoutFlowBuilder = page.Flow().Gap(MASLayoutSpacing.Small).EqualItemWidth()

        Dim primary As MASButton = Window.Controls.AddButton("Save")
        primary.AsPrimary().WithSize(MASSize.[Default])
        flow.Add(primary, MASSize.[Default])

        Dim split As MASSplitButton = Window.Controls.AddSplitButton("Run")
        split.WithSize(MASSize.[Default])
        flow.Add(split, MASSize.[Default])

        Dim query As MASSearchTextBox = Window.Controls.AddSearchTextBox("DataGrid")
        query.Placeholder = "Search component"
        query.WithSize(MASSize.[Default])
        flow.Add(query, MASSize.[Default])

        Dim toggle As MASToggleSwitch = Window.Controls.AddToggleSwitch("RTL ready", checked:=True)
        toggle.WithSize(MASSize.[Default])
        flow.Add(toggle, MASSize.[Default])

        Dim rating As MASRating = Window.Controls.AddRating(4.0R)
        rating.WithSize(MASSize.[Default])
        flow.Add(rating, MASSize.[Default])

        Dim datePicker As MASDatePicker = Window.Controls.AddDatePicker(Date.Today)
        datePicker.WithSize(MASSize.[Default])
        flow.Add(datePicker, MASSize.[Default])

        Dim state As MASValidationMessage = Window.Controls.AddValidationMessage("Input, selection, feedback, media, and file surfaces are reached through official MAS controls.", MASTextValidationState.Information)
        state.WithSize(MASSize.FillWidth)
        AddShowcaseContent(page, state, MASSize.FillWidth)
    End Sub

    Private Sub BuildDataAreaPreview(page As MASApplicationLayoutPageBuilder)
        Dim grid As MASApplicationLayoutGridBuilder = page.Grid(3).Gap(MASLayoutSpacing.Medium).EqualItemSize()
        grid.Add(CreateMetric("Readiness", "94%", "Dashboard metrics").WithTrend("+8", MASToastTone.Success), MASSize.FillWidth)
        grid.Add(CreateMetric("Rows", "100k", "Virtualized proof").WithTrend("Large data", MASToastTone.Info), MASSize.FillWidth)
        grid.Add(CreateMetric("Blocked", "3", "Filterable evidence").WithTrend("Review", MASToastTone.Warning), MASSize.FillWidth)

        Dim dataGrid As MASDataGrid = Window.Controls.AddDataGrid()
        dataGrid.AddColumn("Capability", "Capability")
        dataGrid.AddColumn("Control", "Control")
        dataGrid.AddColumn("Result", "Result")
        dataGrid.AddRow("Enterprise table", "MASDataGrid", "Typed columns + virtualized rows")
        dataGrid.AddRow("Analytics dashboard", "MASMetricCard", "Trend samples + readiness state")
        dataGrid.AddRow("Charts", "MASChart + MASChartLegend", "Business visualization surfaces")
        dataGrid.WithSize(MASSize.FillWidth.OffsetHeight(170.0F))
        AddShowcaseContent(page, dataGrid, MASSize.FillWidth)

        Dim dataReadinessProgress As MASProgressBar = Window.Controls.AddProgressBar(Sub(pb As MASProgressBar)
                                                                                        pb.Minimum = 0
                                                                                        pb.Maximum = 100
                                                                                        pb.Value = 94
                                                                                    End Sub)
        dataReadinessProgress.WithSize(MASSize.FillWidth)
        AddShowcaseContent(page, dataReadinessProgress, MASSize.FillWidth)

        Dim list As MASListView = Window.Controls.AddListView(configure:=Sub(view As MASListView)
                                                                  view.WithDetailsView()
                                                                  view.StandaloneChrome()
                                                                  view.AddColumn("Surface", 210.0F)
                                                                  view.AddColumn("Shown through", 260.0F)
                                                                  view.AddColumn("Ownership", 300.0F)
                                                                  view.Add(MASListViewItem.Create("DataGrid / DataView").WithSubItems(New String() {"MASDataGrid", "Typed data and UI state stay MAS-owned."}))
                                                                  view.Add(MASListViewItem.Create("Analytics").WithSubItems(New String() {"MetricCard / DashboardGrid", "Showcase supplies sample values only."}))
                                                                  view.Add(MASListViewItem.Create("Planning").WithSubItems(New String() {"Kanban / Agenda / Carousel", "No storage or scheduler inside Showcase."}))
                                                              End Sub)
        list.WithSize(MASSize.FillWidth.OffsetHeight(190.0F))
        AddShowcaseContent(page, list, MASSize.FillWidth)
    End Sub

    Private Sub BuildLayoutWorkflowAreaPreview(page As MASApplicationLayoutPageBuilder)
        Dim breadcrumb As MASBreadcrumb = Window.Controls.AddBreadcrumb(New String() {"Showcase", "Product areas", "Layout / Workflow"})
        breadcrumb.WithSize(MASSize.FillWidth)
        AddShowcaseContent(page, breadcrumb, MASSize.FillWidth)

        Dim grid As MASApplicationLayoutGridBuilder = page.Grid(3).Gap(MASLayoutSpacing.Medium).EqualItemSize()
        grid.Add(CreateMetric("Layout", "Semantic", "Grid / Flow / Gallery").WithTrend("Responsive", MASToastTone.Success), MASSize.FillWidth)
        grid.Add(CreateMetric("Workflow", "Guided", "Stepper / Wizard").WithTrend("Public controls", MASToastTone.Info), MASSize.FillWidth)
        grid.Add(CreateMetric("Navigation", "Productive", "Rail / bars / palette").WithTrend("Recipe", MASToastTone.Info), MASSize.FillWidth)

        Dim stepper As MASStepper = Window.Controls.AddStepper(MASStepperOrientation.Horizontal, Sub(control As MASStepper)
                                                                                                      control.AddStep("Shell", "MASApplicationWindow.Pages")
                                                                                                      control.AddStep("Workspace", "Semantic Layout builders")
                                                                                                      control.AddStep("Flow", "Stepper / Wizard / Command surfaces")
                                                                                                      control.CurrentIndex = 1
                                                                                                      control.WithSize(MASSize.FillWidth)
                                                                                                  End Sub)
        AddShowcaseContent(page, stepper, MASSize.FillWidth)
        AddShowcaseContent(page, CreateMuted("Open the Workflow and Productivity pages from the full-width MASMenuBar, guided journeys, or capability discovery matrix."), MASSize.FillWidth)
    End Sub

    Private Sub BuildThemeLocalizationAreaPreview(page As MASApplicationLayoutPageBuilder)
        Dim flow As MASApplicationLayoutFlowBuilder = page.Flow().Gap(MASLayoutSpacing.Small).EqualItemWidth()

        Dim themePicker As MASComboBox = Window.Controls.AddComboBox(New String() {"Light", "Dark", "High contrast", "RTL stress"}, selectedIndex:=0)
        themePicker.WithSize(MASSize.[Default])
        flow.Add(themePicker, MASSize.[Default])

        Dim segment As MASSegmentedControl = Window.Controls.AddSegmentedControl(segments:=New MASSegmentEntry() {New MASSegmentEntry("en", "EN"), New MASSegmentEntry("de", "DE"), New MASSegmentEntry("ar", "AR")}, configure:=Sub(seg As MASSegmentedControl) seg.WithSelectedId("ar"))
        segment.WithSize(MASSize.[Default])
        flow.Add(segment, MASSize.[Default])

        Dim themeStatus As MASStatusBanner = Window.Controls.AddStatusBanner("Theme + direction", "The preview selects sample labels only; Nexamas.UI owns palette, material recipes, RTL direction, text measurement, and motion consumers.", MASToastTone.Success)
        themeStatus.WithSize(MASSize.FillWidth)
        AddShowcaseContent(page, themeStatus, MASSize.FillWidth)

        Dim rtlNote As MASValidationMessage = Window.Controls.AddValidationMessage("Preview only selects sample culture labels; Nexamas.UI owns theme, surface, localization, RTL, and motion behavior.", MASTextValidationState.Success)
        rtlNote.WithSize(MASSize.FillWidth)
        AddShowcaseContent(page, rtlNote, MASSize.FillWidth)
    End Sub

    Private Sub BuildOutputAreaPreview(page As MASApplicationLayoutPageBuilder)
        Dim outputGrid As MASDataGrid = Window.Controls.AddDataGrid()
        outputGrid.AddColumn("Output", "Output")
        outputGrid.AddColumn("Gateway", "Gateway")
        outputGrid.AddColumn("Boundary", "Boundary")
        outputGrid.AddRow("PNG capture", "MASApplication.Output", "Capture engine remains Nexamas.UI-owned")
        outputGrid.AddRow("File / directory target", "Output SDK", "Showcase supplies target choice only")
        outputGrid.AddRow("Evidence bundle", "Product proof", "Showcase displays proof, never generates engines")
        outputGrid.WithSize(MASSize.FillWidth.OffsetHeight(170.0F))
        AddShowcaseContent(page, outputGrid, MASSize.FillWidth)

        Dim list As MASListView = Window.Controls.AddListView(configure:=Sub(view As MASListView)
                                                                  view.WithDetailsView()
                                                                  view.StandaloneChrome()
                                                                  view.AddColumn("Output capability", 230.0F)
                                                                  view.AddColumn("Status", 160.0F)
                                                                  view.AddColumn("Consumer role", 420.0F)
                                                                  view.Add(MASListViewItem.Create("PNG visual capture").WithSubItems(New String() {"Supported", "Call MASApplication.Output; do not own rendering."}))
                                                                  view.Add(MASListViewItem.Create("Memory / file / directory targets").WithSubItems(New String() {"Supported", "Provide target choice and display result."}))
                                                                  view.Add(MASListViewItem.Create("Evidence bundle").WithSubItems(New String() {"Proof", "Show product evidence; no output engine in Showcase."}))
                                                              End Sub)
        list.WithSize(MASSize.FillWidth.OffsetHeight(190.0F))
        AddShowcaseContent(page, list, MASSize.FillWidth)

        Dim outputProgress As MASOperationProgressBox = Window.Controls.AddOperationProgressBox("Output evidence", "PNG capture, target selection, and product bundle proof are MASApplication.Output-owned.")
        outputProgress.WithSize(MASSize.FillWidth)
        AddShowcaseContent(page, outputProgress, MASSize.FillWidth)
        AddShowcaseContent(page, CreateMuted("Open the Output Product page from the full-width MASMenuBar, guided journeys, or capability discovery matrix."), MASSize.FillWidth)
    End Sub

    Private Sub BuildQualityAreaPreview(page As MASApplicationLayoutPageBuilder)
        Dim grid As MASApplicationLayoutGridBuilder = page.Grid(3).Gap(MASLayoutSpacing.Medium).EqualItemSize()
        grid.Add(CreateMetric("Certification", "PASS", "Commercial summary").WithTrend("Proof", MASToastTone.Success), MASSize.FillWidth)
        grid.Add(CreateMetric("Coverage", "Mapped", "Element matrix").WithTrend("Audit", MASToastTone.Info), MASSize.FillWidth)
        grid.Add(CreateMetric("Snapshots", "Owned", "Render verification").WithTrend("Nexamas.UI", MASToastTone.Success), MASSize.FillWidth)

        Dim qualityGrid As MASDataGrid = Window.Controls.AddDataGrid()
        qualityGrid.AddColumn("Proof", "Proof")
        qualityGrid.AddColumn("Evidence page", "Evidence page")
        qualityGrid.AddColumn("Ownership", "Ownership")
        qualityGrid.AddRow("Commercial readiness", "Certification Center", "Shows Nexamas.UI proof without importing gates")
        qualityGrid.AddRow("Element surface coverage", "Element Coverage", "Maps public controls to live pages")
        qualityGrid.AddRow("Render verification", "Render Verification", "PNG proof remains Nexamas.UI-owned")
        qualityGrid.WithSize(MASSize.FillWidth.OffsetHeight(170.0F))
        AddShowcaseContent(page, qualityGrid, MASSize.FillWidth)

        Dim proofProgress As MASProgressBar = Window.Controls.AddProgressBar(Sub(pb As MASProgressBar)
                                                                                  pb.Minimum = 0
                                                                                  pb.Maximum = 100
                                                                                  pb.Value = 92
                                                                              End Sub)
        proofProgress.WithSize(MASSize.FillWidth)
        AddShowcaseContent(page, proofProgress, MASSize.FillWidth)

        Dim list As MASListView = Window.Controls.AddListView(configure:=Sub(view As MASListView)
                                                                  view.WithDetailsView()
                                                                  view.StandaloneChrome()
                                                                  view.AddColumn("Proof page", 230.0F)
                                                                  view.AddColumn("Why it lives here", 520.0F)
                                                                  view.Add(MASListViewItem.Create("Certification Center").WithSubItems(New String() {"Buyer-facing summary without importing internal certification engines."}))
                                                                  view.Add(MASListViewItem.Create("Element Coverage").WithSubItems(New String() {"Evidence and gaps belong in Quality, not the first product impression."}))
                                                                  view.Add(MASListViewItem.Create("Render Verification").WithSubItems(New String() {"PNG baseline/current/diff proof remains Nexamas.UI-owned."}))
                                                              End Sub)
        list.WithSize(MASSize.FillWidth.OffsetHeight(190.0F))
        AddShowcaseContent(page, list, MASSize.FillWidth)
    End Sub

End Class
