#pragma once

#include <SDL3/SDL.h>
#include <compare>

namespace quokka_gfx
{
//--------------------------------------------------------------
struct Color
{
  uint8_t r = 255;
  uint8_t g = 255;
  uint8_t b = 255;
  uint8_t a = 255;

  constexpr Color() = default;                                                        // Default Constructor
  constexpr Color(uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = 255);     // Constructor
  explicit constexpr Color(uint32_t hexColor);                                        // Constructor

  [[nodiscard]] constexpr auto operator<=>(const Color &) const = default;     // Three-way comparison operator
  [[nodiscard]] constexpr      operator SDL_Color() const;                     // Convert Color to SDL_Color
  [[nodiscard]] constexpr      operator SDL_FColor() const;                    // Convert Color to SDL_FColor

  [[nodiscard]] constexpr uint32_t   toHex() const;            // Convert Color to hex representation
  [[nodiscard]] constexpr SDL_Color  toSDL_Color() const;      // Convert Color to SDL_Color
  [[nodiscard]] constexpr SDL_FColor toSDL_FColor() const;     // Convert Color to SDL_FColor

  // Predefined Colors
  static const Color Black;
  static const Color White;
  static const Color Red;
  static const Color Green;
  static const Color Blue;
  static const Color Yellow;
  static const Color Magenta;
  static const Color Cyan;
  static const Color Transparent;
};
//--------------------------------------------------------------
///* Constructor */
// inline constexpr Color::Color(const uint8_t red, const uint8_t green, const uint8_t blue, const uint8_t alpha)
//   : r(red)
//   , g(green)
//   , b(blue)
//   , a(alpha)
//{
// }
////--------------------------------------------------------------
///* Constructor */
// inline constexpr Color::Color(const uint32_t hexColor)
//   : r((hexColor >> 16) & 0xFF)
//   , g((hexColor >> 8) & 0xFF)
//   , b(hexColor & 0xFF)
//   , a((hexColor >> 24) & 0xFF ? (hexColor >> 24) & 0xFF : 255)
//{
// }
////--------------------------------------------------------------
///* Convert Color to SDL_Color */
// inline constexpr Color::operator SDL_Color() const
//{
//   return toSDL_Color();
// }
////--------------------------------------------------------------
///* Convert Color to SDL_FColor */
// inline constexpr Color::operator SDL_FColor() const
//{
//   return toSDL_FColor();
// }
////--------------------------------------------------------------
///* Convert Color to hex representation */
// inline constexpr uint32_t Color::toHex() const
//{
//   return (static_cast<uint32_t>(a) << 24) |
//          (static_cast<uint32_t>(r) << 16) |
//          (static_cast<uint32_t>(g) << 8) |
//          static_cast<uint32_t>(b);
// }
////--------------------------------------------------------------
///* Convert Color to SDL_Color */
// inline constexpr SDL_Color Color::toSDL_Color() const
//{
//   return SDL_Color{ r, g, b, a };
// }
////--------------------------------------------------------------
///* Convert Color to SDL_FColor */
// inline constexpr SDL_FColor Color::toSDL_FColor() const
//{
//   return SDL_FColor{ r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f };
// }
//--------------------------------------------------------------
}     // namespace quokka_gfx
