///
/// HapticPreset.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::haptic {

  /**
   * An enum which can be represented as a JavaScript union (HapticPreset).
   */
  enum class HapticPreset {
    SELECTION      SWIFT_NAME(selection) = 0,
    IMPACTLIGHT      SWIFT_NAME(impactlight) = 1,
    IMPACTMEDIUM      SWIFT_NAME(impactmedium) = 2,
    IMPACTHEAVY      SWIFT_NAME(impactheavy) = 3,
    IMPACTSOFT      SWIFT_NAME(impactsoft) = 4,
    IMPACTRIGID      SWIFT_NAME(impactrigid) = 5,
    NOTIFICATIONSUCCESS      SWIFT_NAME(notificationsuccess) = 6,
    NOTIFICATIONWARNING      SWIFT_NAME(notificationwarning) = 7,
    NOTIFICATIONERROR      SWIFT_NAME(notificationerror) = 8,
  } CLOSED_ENUM;

} // namespace margelo::nitro::haptic

namespace margelo::nitro {

  // C++ HapticPreset <> JS HapticPreset (union)
  template <>
  struct JSIConverter<margelo::nitro::haptic::HapticPreset> final {
    static inline margelo::nitro::haptic::HapticPreset 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("selection"): return margelo::nitro::haptic::HapticPreset::SELECTION;
        case hashString("impactLight"): return margelo::nitro::haptic::HapticPreset::IMPACTLIGHT;
        case hashString("impactMedium"): return margelo::nitro::haptic::HapticPreset::IMPACTMEDIUM;
        case hashString("impactHeavy"): return margelo::nitro::haptic::HapticPreset::IMPACTHEAVY;
        case hashString("impactSoft"): return margelo::nitro::haptic::HapticPreset::IMPACTSOFT;
        case hashString("impactRigid"): return margelo::nitro::haptic::HapticPreset::IMPACTRIGID;
        case hashString("notificationSuccess"): return margelo::nitro::haptic::HapticPreset::NOTIFICATIONSUCCESS;
        case hashString("notificationWarning"): return margelo::nitro::haptic::HapticPreset::NOTIFICATIONWARNING;
        case hashString("notificationError"): return margelo::nitro::haptic::HapticPreset::NOTIFICATIONERROR;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum HapticPreset - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::haptic::HapticPreset arg) {
      switch (arg) {
        case margelo::nitro::haptic::HapticPreset::SELECTION: return JSIConverter<std::string>::toJSI(runtime, "selection");
        case margelo::nitro::haptic::HapticPreset::IMPACTLIGHT: return JSIConverter<std::string>::toJSI(runtime, "impactLight");
        case margelo::nitro::haptic::HapticPreset::IMPACTMEDIUM: return JSIConverter<std::string>::toJSI(runtime, "impactMedium");
        case margelo::nitro::haptic::HapticPreset::IMPACTHEAVY: return JSIConverter<std::string>::toJSI(runtime, "impactHeavy");
        case margelo::nitro::haptic::HapticPreset::IMPACTSOFT: return JSIConverter<std::string>::toJSI(runtime, "impactSoft");
        case margelo::nitro::haptic::HapticPreset::IMPACTRIGID: return JSIConverter<std::string>::toJSI(runtime, "impactRigid");
        case margelo::nitro::haptic::HapticPreset::NOTIFICATIONSUCCESS: return JSIConverter<std::string>::toJSI(runtime, "notificationSuccess");
        case margelo::nitro::haptic::HapticPreset::NOTIFICATIONWARNING: return JSIConverter<std::string>::toJSI(runtime, "notificationWarning");
        case margelo::nitro::haptic::HapticPreset::NOTIFICATIONERROR: return JSIConverter<std::string>::toJSI(runtime, "notificationError");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert HapticPreset 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("selection"):
        case hashString("impactLight"):
        case hashString("impactMedium"):
        case hashString("impactHeavy"):
        case hashString("impactSoft"):
        case hashString("impactRigid"):
        case hashString("notificationSuccess"):
        case hashString("notificationWarning"):
        case hashString("notificationError"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
