//
//  ColorPalettePicker.swift
//  AuraUtility
//
//  Created by Sunny Uppal on 10/22/24.
//

import Foundation
import Adamantium
import SwiftUI

struct ColorPalettePicker: View {
    
    @Binding var selection: SunoColorPalette
    
    var body: some View {
        Picker("", selection: $selection) {
            ForEach(SunoColorPalette.selectableValues, id: \.displayString) { value in
                Text(value.displayString)
                    .tag(value)
            }
        }
    }
}

extension SunoColorPalette: Hashable, Equatable {
    public func hash(into hasher: inout Hasher) {
        hasher.combine(displayString)
    }
    
    static var selectableValues: [SunoColorPalette] {
        return [
            .custom(.zero, .zero, .zero),
            .popcornYellow,
            .sunsetOrange,
            .bubblegumPink,
            .vacationViolet,
            .fadedBlue,
            .wallpaperGreen,
            .discoGold,
            .rubikRed,
            .vintageCherry,
            .lavaLavender,
            .laserBlue,
            .neonLime,
            .playgroundSand,
            .californiaTan,
            .arcadeMaroon,
            .mixtapeMauve,
            .electricBlue,
            .cadillacMoss
        ]
    }
    
    func swiftUICodeString(r: Float, g: Float, b: Float) -> String {
        switch self {
        case .backgroundDotCom:
            return ".backgroundDotCom"
        case .popcornYellow:
            return ".popcornYellow"
        case .sunsetOrange:
            return ".sunsetOrange"
        case .bubblegumPink:
            return ".bubblegumPink"
        case .vacationViolet:
            return ".vacationViolet"
        case .fadedBlue:
            return ".fadedBlue"
        case .wallpaperGreen:
            return ".wallpaperGreen"
        case .discoGold:
            return ".discoGold"
        case .rubikRed:
            return ".rubikRed"
        case .vintageCherry:
            return ".vintageCherry"
        case .lavaLavender:
            return ".lavaLavender"
        case .laserBlue:
            return ".laserBlue"
        case .neonLime:
            return ".neonLime"
        case .playgroundSand:
            return ".playgroundSand"
        case .californiaTan:
            return ".californiaTan"
        case .arcadeMaroon:
            return ".arcadeMaroon"
        case .mixtapeMauve:
            return ".mixtapeMauve"
        case .electricBlue:
            return ".electricBlue"
        case .cadillacMoss:
            return ".cadillacMoss"
        case .custom:
            return ".custom(\(r), \(g), \(b))"
        }
    }
    
    var displayString: String {
        switch self {
        case .backgroundDotCom:
            return "Background Dot Com"
        case .popcornYellow:
            return "Popcorn Yellow"
        case .sunsetOrange:
            return "Sunset Orange"
        case .bubblegumPink:
            return "Bubblegum Pink"
        case .vacationViolet:
            return "Vacation Violet"
        case .fadedBlue:
            return "Faded Blue"
        case .wallpaperGreen:
            return "Wallpaper Green"
        case .discoGold:
            return "Disco Gold"
        case .rubikRed:
            return "Rubik Red"
        case .vintageCherry:
            return "Vintage Cherry"
        case .lavaLavender:
            return "Lava Lavender"
        case .laserBlue:
            return "Laser Blue"
        case .neonLime:
            return "Neon Lime"
        case .playgroundSand:
            return "Playground Sand"
        case .californiaTan:
            return "California Tan"
        case .arcadeMaroon:
            return "Arcade Maroon"
        case .mixtapeMauve:
            return "Mixtape Mauve"
        case .electricBlue:
            return "Electric Blue"
        case .cadillacMoss:
            return "Cadillac Moss"
        case .custom:
            return "Custom"
        }
    }
    
    public static func == (lhs: SunoColorPalette, rhs: SunoColorPalette) -> Bool {
        switch lhs {
        case .backgroundDotCom:
            guard case .backgroundDotCom = rhs else { return false }
            return true
        case .popcornYellow:
            guard case .popcornYellow = rhs else { return false }
            return true
        case .sunsetOrange:
            guard case .sunsetOrange = rhs else { return false }
            return true
        case .bubblegumPink:
            guard case .bubblegumPink = rhs else { return false }
            return true
        case .vacationViolet:
            guard case .vacationViolet = rhs else { return false }
            return true
        case .fadedBlue:
            guard case .fadedBlue = rhs else { return false }
            return true
        case .wallpaperGreen:
            guard case .wallpaperGreen = rhs else { return false }
            return true
        case .discoGold:
            guard case .discoGold = rhs else { return false }
            return true
        case .rubikRed:
            guard case .rubikRed = rhs else { return false }
            return true
        case .vintageCherry:
            guard case .vintageCherry = rhs else { return false }
            return true
        case .lavaLavender:
            guard case .lavaLavender = rhs else { return false }
            return true
        case .laserBlue:
            guard case .laserBlue = rhs else { return false }
            return true
        case .neonLime:
            guard case .neonLime = rhs else { return false }
            return true
        case .playgroundSand:
            guard case .playgroundSand = rhs else { return false }
            return true
        case .californiaTan:
            guard case .californiaTan = rhs else { return false }
            return true
        case .arcadeMaroon:
            guard case .arcadeMaroon = rhs else { return false }
            return true
        case .mixtapeMauve:
            guard case .mixtapeMauve = rhs else { return false }
            return true
        case .electricBlue:
            guard case .electricBlue = rhs else { return false }
            return true
        case .cadillacMoss:
            guard case .cadillacMoss = rhs else { return false }
            return true
        case .custom:
            
            guard case .custom = rhs else { return false }
            return true
        }
    }
}
