Option Strict On
Option Explicit On

Imports System
Imports SkiaSharp

Namespace Nexamas.UI.Theming

    ''' <summary>
    ''' Immutable implementation of semantic theme colors.
    ''' </summary>

    <Global.System.ComponentModel.EditorBrowsable(Global.System.ComponentModel.EditorBrowsableState.Advanced)>
    Friend NotInheritable Class SemanticTheme
        Implements IMASSemanticTheme

        Private ReadOnly _success As SKColor
        Private ReadOnly _warning As SKColor
        Private ReadOnly _danger As SKColor
        Private ReadOnly _info As SKColor

        Private ReadOnly _muted As SKColor
        Private ReadOnly _disabled As SKColor
        Private ReadOnly _focusStrong As SKColor
        Private ReadOnly _selectionSoft As SKColor
        Private ReadOnly _navigationAccent As SKColor

        Friend Sub New(success As SKColor,
                       warning As SKColor,
                       danger As SKColor,
                       info As SKColor,
                       muted As SKColor,
                       disabled As SKColor,
                       navigationAccent As SKColor,
                       focusStrong As SKColor,
                       selectionSoft As SKColor)

            ValidateRequiredColor(success, NameOf(success))
            ValidateRequiredColor(warning, NameOf(warning))
            ValidateRequiredColor(danger, NameOf(danger))
            ValidateRequiredColor(info, NameOf(info))
            ValidateRequiredColor(muted, NameOf(muted))
            ValidateRequiredColor(disabled, NameOf(disabled))
            ValidateRequiredColor(focusStrong, NameOf(focusStrong))
            ValidateRequiredColor(selectionSoft, NameOf(selectionSoft))

            _success = success
            _warning = warning
            _danger = danger
            _info = info

            _muted = muted
            _disabled = disabled
            _focusStrong = focusStrong
            _navigationAccent = navigationAccent
            _selectionSoft = selectionSoft
        End Sub

        Public ReadOnly Property NavigationAccent As SKColor Implements IMASSemanticTheme.NavigationAccent
            Get
                Return _navigationAccent
            End Get
        End Property

        Public ReadOnly Property Success As SKColor Implements IMASSemanticTheme.Success
            Get
                Return _success
            End Get
        End Property

        Public ReadOnly Property Warning As SKColor Implements IMASSemanticTheme.Warning
            Get
                Return _warning
            End Get
        End Property

        Public ReadOnly Property Danger As SKColor Implements IMASSemanticTheme.Danger
            Get
                Return _danger
            End Get
        End Property

        Public ReadOnly Property Info As SKColor Implements IMASSemanticTheme.Info
            Get
                Return _info
            End Get
        End Property

        Public ReadOnly Property Muted As SKColor Implements IMASSemanticTheme.Muted
            Get
                Return _muted
            End Get
        End Property

        Public ReadOnly Property Disabled As SKColor Implements IMASSemanticTheme.Disabled
            Get
                Return _disabled
            End Get
        End Property

        Public ReadOnly Property FocusStrong As SKColor Implements IMASSemanticTheme.FocusStrong
            Get
                Return _focusStrong
            End Get
        End Property

        Public ReadOnly Property SelectionSoft As SKColor Implements IMASSemanticTheme.SelectionSoft
            Get
                Return _selectionSoft
            End Get
        End Property

        Private Shared Sub ValidateRequiredColor(color As SKColor, paramName As String)
            If color.Alpha = 0 AndAlso color.Red = 0 AndAlso color.Green = 0 AndAlso color.Blue = 0 Then
                Throw New ArgumentException("Color cannot be empty or fully transparent black.", paramName)
            End If
        End Sub

    End Class

End Namespace