import simd

/**
    SIMD Color Set is a convenience data model to house three sets of color vectors.
    This is currently used in the app to represent a 3 color set for use in contexts like Adamantium.
    Shader based auras accept colors as these simd vectors and some view presets like:
        - AuraView
        - CircleMaskedAuraView

    Use this type of color data in order to render auras in different layers.
    The properties a b and c each represent a single color in the set
    where for example a.x a.y a.z in the vector can be mapped to r g b

    Using AuraUtility will be the easiest way to get / test these values
    Ask @sunny for access to AuraUtility
 */
public struct SIMDColorSet {
    public let a: SIMD3<Float>
    public let b: SIMD3<Float>
    public let c: SIMD3<Float>

    public init(
        a: SIMD3<Float>,
        b: SIMD3<Float>,
        c: SIMD3<Float>
    ) {
        self.a = a
        self.b = b
        self.c = c
    }

    public enum Preset {
        /**
            These three values are used in the main app banner
            `bannerEmpty` is the black aura representing empty space
            `bannerInProgress` is the mostly purple aura during in progress loading
            `bannerComplete` is mostly orange and is used to represent a tappable banner
         */
        case bannerEmpty
        case bannerInProgress
        case bannerComplete

        /**
            These two values are used in the swipe to generate songs interstitial in omniplayer
            `interstitialEmpty` is the black aura representing the background
            `interstitialColor` is the color in the swipe down area that indicates to the user to swipe
         */
        case interstitialEmpty
        case interstitialColor

        public var colorSet: SIMDColorSet {
            switch self {
            case .bannerEmpty:
                return .init(
                    a: .init(x: 0.0, y: 0.0, z: 0.0),
                    b: .init(x: 0.12729782, y: 0.12766936, z: 0.13256463),
                    c: .init(x: 0.0, y: 0.0, z: 0.0)
                )

            case .bannerInProgress:
                return .init(
                    a: .init(x: 0.129411764705882, y: 0.098039215686275, z: 0.474509803921569),
                    b: .init(x: 0.435294117647059, y: 0.098039215686275, z: 0.631372549019608),
                    c: .init(x: 0.647058823529412, y: 0.270588235294118, z: 0.356862745098039)
                )

            case .bannerComplete:
                return .init(
                    a: .init(x: 0.20843384, y: 0.008484551, z: 0.42940527),
                    b: .init(x: 0.5992606, y: 0.18494228, z: 0.55308056),
                    c: .init(x: 0.9540208, y: 0.39742723, z: 0.26091924)
                )

            case .interstitialEmpty:
                let brightness: Float = 0.5
                return .init(
                    a: .init(x: 0.0, y: 0.0, z: 0.0),
                    b: .init(x: 0.12729782 * brightness, y: 0.12766936 * brightness, z: 0.13256463 * brightness),
                    c: .init(x: 0.0, y: 0.0, z: 0.0)
                )

            case .interstitialColor:
                return .init(
                    a: .init(x: 0.07844093, y: 0.0058029653, z: 0.15964699),
                    b: .init(x: 0.30102274, y: 0.09232233, z: 0.27825546),
                    c: .init(x: 0.5369979, y: 0.22423288, z: 0.14830068)
                )
            }
        }
    }
}
