Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic
Imports Nexamas.UI.Components

Namespace Nexamas.UI.Quality

    ''' <summary>
    ''' Friend-only closure gate for Targeted Closure Phase 6. It closes DashboardGrid
    ''' keyboard/a11y resize thresholds and AppLayout/SplitView real host-adoption
    ''' sample evidence without opening public APIs, building a router, or moving
    ''' native shell/page-host ownership into product controls.
    ''' </summary>
    Friend NotInheritable Class MASDashboardResizeHostSampleClosureGate

        Private Sub New()
        End Sub

        Friend Shared Function Passes() As Boolean
            Return EvaluateFindings().Count = 0
        End Function

        Friend Shared Function EvaluateFindings() As IReadOnlyList(Of MASCommercialReadinessFinding)
            Dim findings As New List(Of MASCommercialReadinessFinding)()
            ValidateDashboardKeyboardResizeThresholds(findings)
            ValidateAppLayoutRealHostSample(findings)
            ValidateSplitViewRealHostSample(findings)
            Return findings
        End Function

        Private Shared Sub ValidateDashboardKeyboardResizeThresholds(findings As List(Of MASCommercialReadinessFinding))
            Try
                Dim control As MASDashboardGrid = MASDashboardGrid.Create("Dashboard resize thresholds proof")
                If Not control.HasKeyboardResizeThresholdsForTests() Then
                    findings.Add(New MASCommercialReadinessFinding("dashboardgrid", "DashboardGrid.KeyboardResizeThresholds", MASCommercialReadinessFindingSeverity.Error, "DashboardGrid keyboard/a11y resize threshold proof did not prove bounded spans, hosted widget state, readable resize text, and bounded widget window behavior."))
                End If
            Catch ex As Exception
                Nexamas.UI.Diagnostics.MASExceptionSilencer.SwallowDiagnosticOnly(ex, "MASDashboardResizeHostSampleClosureGate.DashboardGrid")
                findings.Add(New MASCommercialReadinessFinding("dashboardgrid", "DashboardGrid.KeyboardResizeThresholds", MASCommercialReadinessFindingSeverity.Error, "DashboardGrid keyboard/a11y resize threshold proof threw during validation."))
            End Try
        End Sub

        Private Shared Sub ValidateAppLayoutRealHostSample(findings As List(Of MASCommercialReadinessFinding))
            Try
                Dim control As MASAppLayout = MASAppLayout.Create("AppLayout real host adoption sample")
                If Not control.HasRealHostAdoptionSampleForTests() Then
                    findings.Add(New MASCommercialReadinessFinding("applayout", "AppLayout.RealHostAdoptionSample", MASCommercialReadinessFindingSeverity.Error, "AppLayout real host adoption sample did not prove compact/wide host scenarios while keeping routing and PageHost ownership external."))
                End If
            Catch ex As Exception
                Nexamas.UI.Diagnostics.MASExceptionSilencer.SwallowDiagnosticOnly(ex, "MASDashboardResizeHostSampleClosureGate.AppLayout")
                findings.Add(New MASCommercialReadinessFinding("applayout", "AppLayout.RealHostAdoptionSample", MASCommercialReadinessFindingSeverity.Error, "AppLayout real host adoption sample threw during validation."))
            End Try
        End Sub

        Private Shared Sub ValidateSplitViewRealHostSample(findings As List(Of MASCommercialReadinessFinding))
            Try
                Dim control As MASSplitView = MASSplitView.Create("SplitView real host adoption sample")
                If Not control.HasRealHostAdoptionSampleForTests() Then
                    findings.Add(New MASCommercialReadinessFinding("splitview", "SplitView.RealHostAdoptionSample", MASCommercialReadinessFindingSeverity.Error, "SplitView real host adoption sample did not prove focus handoff, announcement intent, persistence intent, and external native shell ownership."))
                End If
            Catch ex As Exception
                Nexamas.UI.Diagnostics.MASExceptionSilencer.SwallowDiagnosticOnly(ex, "MASDashboardResizeHostSampleClosureGate.SplitView")
                findings.Add(New MASCommercialReadinessFinding("splitview", "SplitView.RealHostAdoptionSample", MASCommercialReadinessFindingSeverity.Error, "SplitView real host adoption sample threw during validation."))
            End Try
        End Sub

    End Class

End Namespace
