Option Strict On
Option Explicit On

Imports System
Imports System.Linq

Namespace Nexamas.UI.Virtualization

    ''' <summary>
    ''' Final commercial-lockdown proof for MASVirtualizedItemsSystem. The report joins the benchmark proof, integration proof,
    ''' and professional readiness gate into one stable internal contract that can be consumed by gates, diagnostics, and SDK tests
    ''' without exposing virtualization implementation details as public control API.
    ''' </summary>
    Friend NotInheritable Class MASVirtualizationCommercialProofReport

        Friend Const RequiredBenchmarkScenarioCountValue As Integer = 7
        Friend Const RequiredMaxLogicalItemCountValue As Integer = 100000
        Friend Const RequiredActiveSharedControllerConsumersValue As Integer = 6
        Friend Const RequiredComposedSharedControllerConsumersValue As Integer = 1
        Friend Const RequiredSharedControllerConsumersValue As Integer = 7
        Friend Const RequiredLargeDataWindowingSurfacesValue As Integer = 12
        Friend Const RequiredDomainSpecificWindowingSurfacesValue As Integer = 5
        Friend Const RequiredCompiledDomainWindowingGateCountValue As Integer = 5
        Friend Const RequiredConsumerDiagnosticContextCountValue As Integer = 11
        Friend Const RequiredConsumerDiagnosticCodeCountValue As Integer = 11
        Friend Const RequiredProjectionScopeSurfaceCountValue As Integer = 2
        Friend Const RequiredAccessibleRangeSurfaceCountValue As Integer = 7
        Friend Const RequiredListViewBoundedMeasurementLogicalItemCountValue As Integer = 100000
        Friend Const RequiredTileBoxSinglePlanningLogicalItemCountValue As Integer = 100000
        Friend Const RequiredProjectionScaleLogicalItemCountValue As Integer = 100000
        Friend Const RequiredActiveBehaviorDimensionCountValue As Integer = 10
        Friend Const RequiredLifecycleGovernedConsumerCountValue As Integer = 7
        Friend Const RequiredLifecycleControlRuntimeDispatcherConsumerCountValue As Integer = 5
        Friend Const RequiredLifecycleFloatSessionDispatcherConsumerCountValue As Integer = 1
        Friend Const RequiredLifecycleComposedChildConsumerCountValue As Integer = 1
        Friend Const RequiredDataGridRenderInvalidationPassCountValue As Integer = 8

        Friend Sub New(benchmarkSummary As MASVirtualizationBenchmarkSummary,
                       integrationReport As MASVirtualizationIntegrationReport,
                       professionalReadinessReport As MASVirtualizationReadinessReport,
                       Optional consumerBehaviorReport As MASVirtualizationConsumerBehaviorReport = Nothing,
                       Optional listViewBoundedMeasurementReport As MASListViewBoundedMeasurementReport = Nothing,
                       Optional tileBoxSinglePlanningReport As MASTileBoxSinglePlanningReport = Nothing,
                       Optional consumerLifecycleReport As MASVirtualizationConsumerLifecycleReport = Nothing,
                       Optional largeDataWindowingReport As MASLargeDataWindowingReport = Nothing,
                       Optional largeDataWindowingCatalogCoverageReport As MASLargeDataWindowingCatalogCoverageReport = Nothing,
                       Optional consumerDiagnosticsReport As MASVirtualizationConsumerDiagnosticsReport = Nothing,
                       Optional projectionScopeReport As MASVirtualizationProjectionScopeReport = Nothing,
                       Optional projectionScaleReport As MASVirtualizationProjectionScaleReport = Nothing,
                       Optional accessibleRangeReport As MASVirtualizationAccessibleRangeReport = Nothing,
                       Optional dataGridRenderInvalidationCoalescingReport As MASDataGridRenderInvalidationCoalescingReport = Nothing)
            Me.BenchmarkSummary = benchmarkSummary
            Me.IntegrationReport = integrationReport
            Me.ProfessionalReadinessReport = professionalReadinessReport
            Me.ConsumerBehaviorReport = consumerBehaviorReport
            Me.ListViewBoundedMeasurementReport = listViewBoundedMeasurementReport
            Me.TileBoxSinglePlanningReport = tileBoxSinglePlanningReport
            Me.ConsumerLifecycleReport = consumerLifecycleReport
            Me.LargeDataWindowingReport = largeDataWindowingReport
            Me.LargeDataWindowingCatalogCoverageReport = largeDataWindowingCatalogCoverageReport
            Me.ConsumerDiagnosticsReport = consumerDiagnosticsReport
            Me.ProjectionScopeReport = projectionScopeReport
            Me.ProjectionScaleReport = projectionScaleReport
            Me.AccessibleRangeReport = accessibleRangeReport
            Me.DataGridRenderInvalidationCoalescingReport = dataGridRenderInvalidationCoalescingReport
        End Sub

        Friend ReadOnly Property BenchmarkSummary As MASVirtualizationBenchmarkSummary
        Friend ReadOnly Property IntegrationReport As MASVirtualizationIntegrationReport
        Friend ReadOnly Property ProfessionalReadinessReport As MASVirtualizationReadinessReport
        Friend ReadOnly Property ConsumerBehaviorReport As MASVirtualizationConsumerBehaviorReport
        Friend ReadOnly Property ListViewBoundedMeasurementReport As MASListViewBoundedMeasurementReport
        Friend ReadOnly Property TileBoxSinglePlanningReport As MASTileBoxSinglePlanningReport
        Friend ReadOnly Property ConsumerLifecycleReport As MASVirtualizationConsumerLifecycleReport
        Friend ReadOnly Property LargeDataWindowingReport As MASLargeDataWindowingReport
        Friend ReadOnly Property LargeDataWindowingCatalogCoverageReport As MASLargeDataWindowingCatalogCoverageReport
        Friend ReadOnly Property ConsumerDiagnosticsReport As MASVirtualizationConsumerDiagnosticsReport
        Friend ReadOnly Property ProjectionScopeReport As MASVirtualizationProjectionScopeReport
        Friend ReadOnly Property ProjectionScaleReport As MASVirtualizationProjectionScaleReport
        Friend ReadOnly Property AccessibleRangeReport As MASVirtualizationAccessibleRangeReport
        Friend ReadOnly Property DataGridRenderInvalidationCoalescingReport As MASDataGridRenderInvalidationCoalescingReport

        Friend ReadOnly Property RequiredBenchmarkScenarioCount As Integer
            Get
                Return RequiredBenchmarkScenarioCountValue
            End Get
        End Property

        Friend ReadOnly Property RequiredMaxLogicalItemCount As Integer
            Get
                Return RequiredMaxLogicalItemCountValue
            End Get
        End Property

        Friend ReadOnly Property RequiredActiveSharedControllerConsumers As Integer
            Get
                Return RequiredActiveSharedControllerConsumersValue
            End Get
        End Property

        Friend ReadOnly Property RequiredComposedSharedControllerConsumers As Integer
            Get
                Return RequiredComposedSharedControllerConsumersValue
            End Get
        End Property

        Friend ReadOnly Property RequiredSharedControllerConsumers As Integer
            Get
                Return RequiredSharedControllerConsumersValue
            End Get
        End Property

        Friend ReadOnly Property RequiredLargeDataWindowingSurfaces As Integer
            Get
                Return RequiredLargeDataWindowingSurfacesValue
            End Get
        End Property

        Friend ReadOnly Property RequiredDomainSpecificWindowingSurfaces As Integer
            Get
                Return RequiredDomainSpecificWindowingSurfacesValue
            End Get
        End Property

        Friend ReadOnly Property RequiredCompiledDomainWindowingGateCount As Integer
            Get
                Return RequiredCompiledDomainWindowingGateCountValue
            End Get
        End Property

        Friend ReadOnly Property RequiredConsumerDiagnosticContextCount As Integer
            Get
                Return RequiredConsumerDiagnosticContextCountValue
            End Get
        End Property

        Friend ReadOnly Property RequiredConsumerDiagnosticCodeCount As Integer
            Get
                Return RequiredConsumerDiagnosticCodeCountValue
            End Get
        End Property


        Friend ReadOnly Property RequiredProjectionScopeSurfaceCount As Integer
            Get
                Return RequiredProjectionScopeSurfaceCountValue
            End Get
        End Property

        Friend ReadOnly Property RequiredAccessibleRangeSurfaceCount As Integer
            Get
                Return RequiredAccessibleRangeSurfaceCountValue
            End Get
        End Property

        Friend ReadOnly Property RequiredActiveBehaviorDimensionCount As Integer
            Get
                Return RequiredActiveBehaviorDimensionCountValue
            End Get
        End Property

        Friend ReadOnly Property RequiredLifecycleGovernedConsumerCount As Integer
            Get
                Return RequiredLifecycleGovernedConsumerCountValue
            End Get
        End Property

        Friend ReadOnly Property BenchmarkProofReady As Boolean
            Get
                Return BenchmarkSummary IsNot Nothing AndAlso
                       BenchmarkSummary.IsCommercialProofReady AndAlso
                       BenchmarkSummary.ScenarioCount >= RequiredBenchmarkScenarioCountValue AndAlso
                       BenchmarkSummary.MaxLogicalItemCount >= RequiredMaxLogicalItemCountValue
            End Get
        End Property

        Friend ReadOnly Property ConsumerIntegrationReady As Boolean
            Get
                Return IntegrationReport IsNot Nothing AndAlso
                       IntegrationReport.ReadyForDataGridFoundation AndAlso
                       IntegrationReport.ActiveSharedControllerConsumerCount >= RequiredActiveSharedControllerConsumersValue AndAlso
                       IntegrationReport.ComposedSharedControllerConsumerCount >= RequiredComposedSharedControllerConsumersValue AndAlso
                       IntegrationReport.SharedControllerConsumerCount >= RequiredSharedControllerConsumersValue
            End Get
        End Property

        Friend ReadOnly Property ProfessionalReadinessReady As Boolean
            Get
                Return ProfessionalReadinessReport IsNot Nothing AndAlso ProfessionalReadinessReport.IsReady
            End Get
        End Property

        Friend ReadOnly Property ConsumerBehaviorProofReady As Boolean
            Get
                Return ConsumerBehaviorReport IsNot Nothing AndAlso
                       ConsumerBehaviorReport.IsReady AndAlso
                       ConsumerBehaviorReport.ActiveSharedControllerProofCount >= RequiredActiveSharedControllerConsumersValue AndAlso
                       ConsumerBehaviorReport.ComposedSharedControllerProofCount >= RequiredComposedSharedControllerConsumersValue AndAlso
                       ConsumerBehaviorReport.ProvedConsumerCount >= RequiredSharedControllerConsumersValue AndAlso
                       ConsumerBehaviorReport.RequiredActiveBehaviorDimensionCount >= RequiredActiveBehaviorDimensionCountValue AndAlso
                       ConsumerBehaviorReport.AllActiveConsumersProvedRequiredBehaviorDimensions AndAlso
                       ConsumerBehaviorReport.AllComposedConsumersProvedThroughChildren
            End Get
        End Property

        Friend ReadOnly Property ListViewBoundedMeasurementProofReady As Boolean
            Get
                Return ListViewBoundedMeasurementReport IsNot Nothing AndAlso
                       ListViewBoundedMeasurementReport.IsReady AndAlso
                       ListViewBoundedMeasurementReport.LogicalItemCount >= RequiredListViewBoundedMeasurementLogicalItemCountValue AndAlso
                       ListViewBoundedMeasurementReport.Proves100kVariableHeightInvalidation AndAlso
                       ListViewBoundedMeasurementReport.IsResolverMeasurementBounded AndAlso
                       ListViewBoundedMeasurementReport.IsCacheMeasurementSparse
            End Get
        End Property

        Friend ReadOnly Property TileBoxSinglePlanningProofReady As Boolean
            Get
                Return TileBoxSinglePlanningReport IsNot Nothing AndAlso
                       TileBoxSinglePlanningReport.IsReady AndAlso
                       TileBoxSinglePlanningReport.LogicalItemCount >= RequiredTileBoxSinglePlanningLogicalItemCountValue AndAlso
                       TileBoxSinglePlanningReport.Proves100kTileGridSinglePlanning AndAlso
                       TileBoxSinglePlanningReport.ProvesScrollExtentResolvedBeforePlanning AndAlso
                       TileBoxSinglePlanningReport.ProvesBoundedTileGridRealization
            End Get
        End Property

        Friend ReadOnly Property ConsumerLifecycleProofReady As Boolean
            Get
                Return ConsumerLifecycleReport IsNot Nothing AndAlso
                       ConsumerLifecycleReport.IsReady AndAlso
                       ConsumerLifecycleReport.GovernedConsumerCount >= RequiredLifecycleGovernedConsumerCountValue AndAlso
                       ConsumerLifecycleReport.ActiveControlRuntimeDispatcherConsumerCount >= RequiredLifecycleControlRuntimeDispatcherConsumerCountValue AndAlso
                       ConsumerLifecycleReport.FloatSessionDispatcherConsumerCount >= RequiredLifecycleFloatSessionDispatcherConsumerCountValue AndAlso
                       ConsumerLifecycleReport.ComposedChildLifecycleConsumerCount >= RequiredLifecycleComposedChildConsumerCountValue AndAlso
                       ConsumerLifecycleReport.AllActiveConsumersHaveOfficialDispatcherLifecycle AndAlso
                       ConsumerLifecycleReport.AllComposedConsumersHaveChildLifecycleProof
            End Get
        End Property

        Friend ReadOnly Property LargeDataWindowingProofReady As Boolean
            Get
                Return LargeDataWindowingReport IsNot Nothing AndAlso
                       LargeDataWindowingReport.IsReady AndAlso
                       LargeDataWindowingReport.ProvedSurfaceCount >= RequiredLargeDataWindowingSurfacesValue AndAlso
                       LargeDataWindowingReport.ProvedSharedControllerSurfaceCount >= RequiredSharedControllerConsumersValue AndAlso
                       LargeDataWindowingReport.ProvedDomainSpecificWindowingSurfaceCount >= RequiredDomainSpecificWindowingSurfacesValue
            End Get
        End Property

        Friend ReadOnly Property LargeDataWindowingCatalogCoverageProofReady As Boolean
            Get
                Return LargeDataWindowingCatalogCoverageReport IsNot Nothing AndAlso
                       LargeDataWindowingCatalogCoverageReport.IsReady AndAlso
                       LargeDataWindowingCatalogCoverageReport.CompiledDomainWindowingGateTypeCount >= RequiredCompiledDomainWindowingGateCountValue AndAlso
                       LargeDataWindowingCatalogCoverageReport.CatalogDomainProofRouteCount >= RequiredDomainSpecificWindowingSurfacesValue AndAlso
                       LargeDataWindowingCatalogCoverageReport.AllCompiledDomainWindowingGatesCataloged AndAlso
                       LargeDataWindowingCatalogCoverageReport.AllCatalogDomainRoutesResolveToCompiledGates
            End Get
        End Property

        Friend ReadOnly Property ConsumerDiagnosticsProofReady As Boolean
            Get
                Return ConsumerDiagnosticsReport IsNot Nothing AndAlso
                       ConsumerDiagnosticsReport.IsReady AndAlso
                       ConsumerDiagnosticsReport.RequiredDiagnosticContextCount >= RequiredConsumerDiagnosticContextCountValue AndAlso
                       ConsumerDiagnosticsReport.PublishedDiagnosticContextCount >= RequiredConsumerDiagnosticContextCountValue AndAlso
                       ConsumerDiagnosticsReport.RequiredDiagnosticCodeCount >= RequiredConsumerDiagnosticCodeCountValue AndAlso
                       ConsumerDiagnosticsReport.PublishedDiagnosticCodeCount >= RequiredConsumerDiagnosticCodeCountValue
            End Get
        End Property


        Friend ReadOnly Property ProjectionScopeProofReady As Boolean
            Get
                Return ProjectionScopeReport IsNot Nothing AndAlso
                       ProjectionScopeReport.IsReady AndAlso
                       ProjectionScopeReport.ProjectionScopeSurfaceCount >= RequiredProjectionScopeSurfaceCountValue AndAlso
                       ProjectionScopeReport.SurfaceOwnedProjectionCount >= RequiredProjectionScopeSurfaceCountValue AndAlso
                       ProjectionScopeReport.NoVirtualizationCoreProjectionOwnership AndAlso
                       ProjectionScopeReport.AllProjectionScaleRequiresSeparateGate AndAlso
                       ProjectionScopeReport.AllFullProjectionPassesAreExplicit
            End Get
        End Property

        Friend ReadOnly Property ProjectionScaleProofReady As Boolean
            Get
                Return ProjectionScaleReport IsNot Nothing AndAlso
                       ProjectionScaleReport.IsReady AndAlso
                       ProjectionScaleReport.LogicalItemCount >= RequiredProjectionScaleLogicalItemCountValue AndAlso
                       ProjectionScaleReport.Proves100kDataViewFilterSortGroupIndependentFromRender AndAlso
                       ProjectionScaleReport.Proves100kTreeExpandIndependentFromRender AndAlso
                       ProjectionScaleReport.NoRenderWindowDependency
            End Get
        End Property



        Friend ReadOnly Property AccessibleRangeProofReady As Boolean
            Get
                Return AccessibleRangeReport IsNot Nothing AndAlso
                       AccessibleRangeReport.IsReady AndAlso
                       AccessibleRangeReport.AccessibleRangeSurfaceCount >= RequiredAccessibleRangeSurfaceCountValue AndAlso
                       AccessibleRangeReport.ProvedAccessibleRangeSurfaceCount >= RequiredAccessibleRangeSurfaceCountValue AndAlso
                       AccessibleRangeReport.ActiveAccessibleRangeProofCount >= RequiredActiveSharedControllerConsumersValue AndAlso
                       AccessibleRangeReport.ComposedAccessibleRangeProofCount >= RequiredComposedSharedControllerConsumersValue AndAlso
                       AccessibleRangeReport.AllBindingsExposeLogicalPositionMetadata AndAlso
                       AccessibleRangeReport.AllBindingsUseScrollToIndexBridge AndAlso
                       AccessibleRangeReport.AllSnapshotsBoundedToRealizedRange
            End Get
        End Property


        Friend ReadOnly Property DataGridRenderInvalidationCoalescingProofReady As Boolean
            Get
                Return DataGridRenderInvalidationCoalescingReport IsNot Nothing AndAlso
                       DataGridRenderInvalidationCoalescingReport.IsReady AndAlso
                       DataGridRenderInvalidationCoalescingReport.ResizePassCount + DataGridRenderInvalidationCoalescingReport.ScrollPassCount >= RequiredDataGridRenderInvalidationPassCountValue AndAlso
                       DataGridRenderInvalidationCoalescingReport.NoRenderPhaseInvalidationForwarded AndAlso
                       DataGridRenderInvalidationCoalescingReport.OutsideRenderInvalidationStillForwarded
            End Get
        End Property

        Friend ReadOnly Property AllBindingsRequireInvalidationAndBoundaryAudit As Boolean
            Get
                If IntegrationReport Is Nothing OrElse IntegrationReport.Bindings Is Nothing OrElse IntegrationReport.Bindings.Count = 0 Then Return False
                Return Global.System.Linq.Enumerable.All(IntegrationReport.Bindings, Function(binding) binding.RequiresAutoInvalidationCoordinator AndAlso binding.RequiresConsumerBoundaryAudit)
            End Get
        End Property

        Friend ReadOnly Property HasHierarchicalTreeProof As Boolean
            Get
                If IntegrationReport Is Nothing OrElse IntegrationReport.Bindings Is Nothing Then Return False
                Return Global.System.Linq.Enumerable.Any(IntegrationReport.Bindings, Function(binding) String.Equals(binding.Id, "MASTreeView", Global.System.StringComparison.Ordinal) AndAlso binding.ConsumesSharedController AndAlso binding.ExtentStrategy = MASVirtualizationExtentStrategy.HierarchicalVisibleProjection)
            End Get
        End Property

        Friend ReadOnly Property HasTileGridProof As Boolean
            Get
                If IntegrationReport Is Nothing OrElse IntegrationReport.Bindings Is Nothing Then Return False
                Return Global.System.Linq.Enumerable.Any(IntegrationReport.Bindings, Function(binding) String.Equals(binding.Id, "MASTileBox", Global.System.StringComparison.Ordinal) AndAlso binding.ConsumesSharedController AndAlso binding.ExtentStrategy = MASVirtualizationExtentStrategy.TileGridMeasuredCells)
            End Get
        End Property

        Friend ReadOnly Property HasComposedFileExplorerProof As Boolean
            Get
                If IntegrationReport Is Nothing OrElse IntegrationReport.Bindings Is Nothing Then Return False
                Return Global.System.Linq.Enumerable.Any(
                    IntegrationReport.Bindings,
                    Function(binding) String.Equals(binding.Id, "MASFileExplorerView", Global.System.StringComparison.Ordinal) AndAlso
                                      binding.Stage = MASVirtualizationIntegrationStage.ComposedSharedControllerConsumer AndAlso
                                      binding.IsComposedSharedControllerConsumer AndAlso
                                      Global.System.Linq.Enumerable.Contains(binding.ComposedThroughConsumerIds, "MASTreeView") AndAlso
                                      Global.System.Linq.Enumerable.Contains(binding.ComposedThroughConsumerIds, "MASListView"))
            End Get
        End Property

        Friend ReadOnly Property IsReadyForCommercialLockdown As Boolean
            Get
                Return BenchmarkProofReady AndAlso
                       ConsumerIntegrationReady AndAlso
                       ProfessionalReadinessReady AndAlso
                       ConsumerBehaviorProofReady AndAlso
                       ListViewBoundedMeasurementProofReady AndAlso
                       TileBoxSinglePlanningProofReady AndAlso
                       ConsumerLifecycleProofReady AndAlso
                       LargeDataWindowingProofReady AndAlso
                       LargeDataWindowingCatalogCoverageProofReady AndAlso
                       ConsumerDiagnosticsProofReady AndAlso
                       ProjectionScopeProofReady AndAlso
                       ProjectionScaleProofReady AndAlso
                       AccessibleRangeProofReady AndAlso
                       DataGridRenderInvalidationCoalescingProofReady AndAlso
                       AllBindingsRequireInvalidationAndBoundaryAudit AndAlso
                       HasHierarchicalTreeProof AndAlso
                       HasTileGridProof AndAlso
                       HasComposedFileExplorerProof
            End Get
        End Property

        Friend ReadOnly Property CommercialProofLabel As String
            Get
                Return "Virtualization commercial proof: 100k benchmark, bounded realization, 100k MASListView variable-height bounded measurement invalidation, 100k MASTileBox single-planning proof, 6 active shared-controller consumers, 10 behavior dimensions per active consumer, unified dispatcher/lifecycle proof for 7 catalog consumers, 1 composed FileExplorer consumer, executed behavior proof, 5 domain-specific large-data windowing proofs, compiled catalog coverage for all domain-specific WindowingGate routes, structured consumer diagnostic-code proof, strict consumer diagnostics, explicit projection-scope ownership, 100k source/projection scale proof, accessible virtual-range navigation, and DataGrid render/layout invalidation coalescing."
            End Get
        End Property

    End Class

End Namespace
