///
/// Alignment.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#if __has_include(<NitroModules/NitroHash.hpp>)
#include <NitroModules/NitroHash.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/JSIConverter.hpp>)
#include <NitroModules/JSIConverter.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/NitroDefines.hpp>)
#include <NitroModules/NitroDefines.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

namespace margelo::nitro::rive {

  /**
   * An enum which can be represented as a JavaScript union (Alignment).
   */
  enum class Alignment {
    TOPLEFT      SWIFT_NAME(topleft) = 0,
    TOPCENTER      SWIFT_NAME(topcenter) = 1,
    TOPRIGHT      SWIFT_NAME(topright) = 2,
    CENTERLEFT      SWIFT_NAME(centerleft) = 3,
    CENTER      SWIFT_NAME(center) = 4,
    CENTERRIGHT      SWIFT_NAME(centerright) = 5,
    BOTTOMLEFT      SWIFT_NAME(bottomleft) = 6,
    BOTTOMCENTER      SWIFT_NAME(bottomcenter) = 7,
    BOTTOMRIGHT      SWIFT_NAME(bottomright) = 8,
  } CLOSED_ENUM;

} // namespace margelo::nitro::rive

namespace margelo::nitro {

  // C++ Alignment <> JS Alignment (union)
  template <>
  struct JSIConverter<margelo::nitro::rive::Alignment> final {
    static inline margelo::nitro::rive::Alignment fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("topLeft"): return margelo::nitro::rive::Alignment::TOPLEFT;
        case hashString("topCenter"): return margelo::nitro::rive::Alignment::TOPCENTER;
        case hashString("topRight"): return margelo::nitro::rive::Alignment::TOPRIGHT;
        case hashString("centerLeft"): return margelo::nitro::rive::Alignment::CENTERLEFT;
        case hashString("center"): return margelo::nitro::rive::Alignment::CENTER;
        case hashString("centerRight"): return margelo::nitro::rive::Alignment::CENTERRIGHT;
        case hashString("bottomLeft"): return margelo::nitro::rive::Alignment::BOTTOMLEFT;
        case hashString("bottomCenter"): return margelo::nitro::rive::Alignment::BOTTOMCENTER;
        case hashString("bottomRight"): return margelo::nitro::rive::Alignment::BOTTOMRIGHT;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum Alignment - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::rive::Alignment arg) {
      switch (arg) {
        case margelo::nitro::rive::Alignment::TOPLEFT: return JSIConverter<std::string>::toJSI(runtime, "topLeft");
        case margelo::nitro::rive::Alignment::TOPCENTER: return JSIConverter<std::string>::toJSI(runtime, "topCenter");
        case margelo::nitro::rive::Alignment::TOPRIGHT: return JSIConverter<std::string>::toJSI(runtime, "topRight");
        case margelo::nitro::rive::Alignment::CENTERLEFT: return JSIConverter<std::string>::toJSI(runtime, "centerLeft");
        case margelo::nitro::rive::Alignment::CENTER: return JSIConverter<std::string>::toJSI(runtime, "center");
        case margelo::nitro::rive::Alignment::CENTERRIGHT: return JSIConverter<std::string>::toJSI(runtime, "centerRight");
        case margelo::nitro::rive::Alignment::BOTTOMLEFT: return JSIConverter<std::string>::toJSI(runtime, "bottomLeft");
        case margelo::nitro::rive::Alignment::BOTTOMCENTER: return JSIConverter<std::string>::toJSI(runtime, "bottomCenter");
        case margelo::nitro::rive::Alignment::BOTTOMRIGHT: return JSIConverter<std::string>::toJSI(runtime, "bottomRight");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert Alignment to JS - invalid value: "
                                    + std::to_string(static_cast<int>(arg)) + "!");
      }
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isString()) {
        return false;
      }
      std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
      switch (hashString(unionValue.c_str(), unionValue.size())) {
        case hashString("topLeft"):
        case hashString("topCenter"):
        case hashString("topRight"):
        case hashString("centerLeft"):
        case hashString("center"):
        case hashString("centerRight"):
        case hashString("bottomLeft"):
        case hashString("bottomCenter"):
        case hashString("bottomRight"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
