Option Strict On
Option Explicit On

Namespace Nexamas.UI.Components

    ''' <summary>
    ''' Central Friend-only factory for route/shell ownership boundary snapshots.
    ''' It keeps the policy explicit: product controls may expose host-facing
    ''' boundary evidence, but they must not silently become routers, page hosts,
    ''' public adapter providers, or native shells.
    ''' </summary>
    Friend NotInheritable Class MASRouteShellBoundaryPolicy
        Private Sub New()
        End Sub

        Friend Shared Function CreateAppLayoutBoundary() As MASRouteShellBoundarySnapshot
            Return New MASRouteShellBoundarySnapshot(
                1,
                "applayout",
                MASRouteShellBoundaryKind.AppLayoutRouteOwnership,
                "AppLayout.RoutingOwnership",
                ownsRouter:=False,
                ownsPageHost:=False,
                ownsNativeShell:=False,
                exposesPublicAdapter:=False,
                observesExternalRoute:=False,
                providesHostBoundarySnapshot:=True,
                boundaryNote:="AppLayout remains a visual slot layout surface. Route registration, same-window page hosting, and native shell integration belong to the application facade, not this control.")
        End Function

        Friend Shared Function CreateMasterDetailBoundary() As MASRouteShellBoundarySnapshot
            Return New MASRouteShellBoundarySnapshot(
                1,
                "masterdetail",
                MASRouteShellBoundaryKind.MasterDetailRoutingAdapterBoundary,
                "MasterDetail.RoutingPublicAdapter",
                ownsRouter:=False,
                ownsPageHost:=False,
                ownsNativeShell:=False,
                exposesPublicAdapter:=False,
                observesExternalRoute:=False,
                providesHostBoundarySnapshot:=True,
                boundaryNote:="MasterDetailView remains a visual/source-projection surface. Routing and public adapter decisions stay outside the control until an explicit public adapter policy is approved.")
        End Function

        Friend Shared Function CreateSplitViewBoundary() As MASRouteShellBoundarySnapshot
            Return New MASRouteShellBoundarySnapshot(
                1,
                "splitview",
                MASRouteShellBoundaryKind.SplitViewShellIntegrationBoundary,
                "SplitView.ShellIntegration",
                ownsRouter:=False,
                ownsPageHost:=False,
                ownsNativeShell:=False,
                exposesPublicAdapter:=False,
                observesExternalRoute:=False,
                providesHostBoundarySnapshot:=True,
                boundaryNote:="SplitView owns pane ratios and splitter focus only. Shell announcements, persistence of pane intent, and host focus coordination remain host responsibilities backed by this boundary snapshot.")
        End Function

        Friend Shared Function IsSafeClosedBoundary(snapshot As MASRouteShellBoundarySnapshot,
                                                   expectedOwnerKey As String,
                                                   expectedEvidenceKey As String,
                                                   expectedKind As MASRouteShellBoundaryKind) As Boolean
            If snapshot Is Nothing Then Return False
            If Not snapshot.IsProductionSafeBoundary Then Return False
            If snapshot.Kind <> expectedKind Then Return False
            If Not System.String.Equals(snapshot.OwnerKey, If(expectedOwnerKey, System.String.Empty).Trim(), System.StringComparison.OrdinalIgnoreCase) Then Return False
            If Not System.String.Equals(snapshot.EvidenceKey, If(expectedEvidenceKey, System.String.Empty).Trim(), System.StringComparison.OrdinalIgnoreCase) Then Return False
            Return True
        End Function
    End Class

End Namespace
