///
/// GeneralForm.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::healthkit {

  /**
   * An enum which can be represented as a JavaScript union (GeneralForm).
   */
  enum class GeneralForm {
    DEVICE      SWIFT_NAME(device) = 0,
    UNKNOWN      SWIFT_NAME(unknown) = 1,
    CAPSULE      SWIFT_NAME(capsule) = 2,
    CREAM      SWIFT_NAME(cream) = 3,
    DROPS      SWIFT_NAME(drops) = 4,
    FOAM      SWIFT_NAME(foam) = 5,
    GEL      SWIFT_NAME(gel) = 6,
    INHALER      SWIFT_NAME(inhaler) = 7,
    INJECTION      SWIFT_NAME(injection) = 8,
    LIQUID      SWIFT_NAME(liquid) = 9,
    LOTION      SWIFT_NAME(lotion) = 10,
    OINTMENT      SWIFT_NAME(ointment) = 11,
    PATCH      SWIFT_NAME(patch) = 12,
    POWDER      SWIFT_NAME(powder) = 13,
    SPRAY      SWIFT_NAME(spray) = 14,
    SUPPOSITORY      SWIFT_NAME(suppository) = 15,
    TABLET      SWIFT_NAME(tablet) = 16,
    TOPICAL      SWIFT_NAME(topical) = 17,
  } CLOSED_ENUM;

} // namespace margelo::nitro::healthkit

namespace margelo::nitro {

  // C++ GeneralForm <> JS GeneralForm (union)
  template <>
  struct JSIConverter<margelo::nitro::healthkit::GeneralForm> final {
    static inline margelo::nitro::healthkit::GeneralForm 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("device"): return margelo::nitro::healthkit::GeneralForm::DEVICE;
        case hashString("unknown"): return margelo::nitro::healthkit::GeneralForm::UNKNOWN;
        case hashString("capsule"): return margelo::nitro::healthkit::GeneralForm::CAPSULE;
        case hashString("cream"): return margelo::nitro::healthkit::GeneralForm::CREAM;
        case hashString("drops"): return margelo::nitro::healthkit::GeneralForm::DROPS;
        case hashString("foam"): return margelo::nitro::healthkit::GeneralForm::FOAM;
        case hashString("gel"): return margelo::nitro::healthkit::GeneralForm::GEL;
        case hashString("inhaler"): return margelo::nitro::healthkit::GeneralForm::INHALER;
        case hashString("injection"): return margelo::nitro::healthkit::GeneralForm::INJECTION;
        case hashString("liquid"): return margelo::nitro::healthkit::GeneralForm::LIQUID;
        case hashString("lotion"): return margelo::nitro::healthkit::GeneralForm::LOTION;
        case hashString("ointment"): return margelo::nitro::healthkit::GeneralForm::OINTMENT;
        case hashString("patch"): return margelo::nitro::healthkit::GeneralForm::PATCH;
        case hashString("powder"): return margelo::nitro::healthkit::GeneralForm::POWDER;
        case hashString("spray"): return margelo::nitro::healthkit::GeneralForm::SPRAY;
        case hashString("suppository"): return margelo::nitro::healthkit::GeneralForm::SUPPOSITORY;
        case hashString("tablet"): return margelo::nitro::healthkit::GeneralForm::TABLET;
        case hashString("topical"): return margelo::nitro::healthkit::GeneralForm::TOPICAL;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum GeneralForm - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::healthkit::GeneralForm arg) {
      switch (arg) {
        case margelo::nitro::healthkit::GeneralForm::DEVICE: return JSIConverter<std::string>::toJSI(runtime, "device");
        case margelo::nitro::healthkit::GeneralForm::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
        case margelo::nitro::healthkit::GeneralForm::CAPSULE: return JSIConverter<std::string>::toJSI(runtime, "capsule");
        case margelo::nitro::healthkit::GeneralForm::CREAM: return JSIConverter<std::string>::toJSI(runtime, "cream");
        case margelo::nitro::healthkit::GeneralForm::DROPS: return JSIConverter<std::string>::toJSI(runtime, "drops");
        case margelo::nitro::healthkit::GeneralForm::FOAM: return JSIConverter<std::string>::toJSI(runtime, "foam");
        case margelo::nitro::healthkit::GeneralForm::GEL: return JSIConverter<std::string>::toJSI(runtime, "gel");
        case margelo::nitro::healthkit::GeneralForm::INHALER: return JSIConverter<std::string>::toJSI(runtime, "inhaler");
        case margelo::nitro::healthkit::GeneralForm::INJECTION: return JSIConverter<std::string>::toJSI(runtime, "injection");
        case margelo::nitro::healthkit::GeneralForm::LIQUID: return JSIConverter<std::string>::toJSI(runtime, "liquid");
        case margelo::nitro::healthkit::GeneralForm::LOTION: return JSIConverter<std::string>::toJSI(runtime, "lotion");
        case margelo::nitro::healthkit::GeneralForm::OINTMENT: return JSIConverter<std::string>::toJSI(runtime, "ointment");
        case margelo::nitro::healthkit::GeneralForm::PATCH: return JSIConverter<std::string>::toJSI(runtime, "patch");
        case margelo::nitro::healthkit::GeneralForm::POWDER: return JSIConverter<std::string>::toJSI(runtime, "powder");
        case margelo::nitro::healthkit::GeneralForm::SPRAY: return JSIConverter<std::string>::toJSI(runtime, "spray");
        case margelo::nitro::healthkit::GeneralForm::SUPPOSITORY: return JSIConverter<std::string>::toJSI(runtime, "suppository");
        case margelo::nitro::healthkit::GeneralForm::TABLET: return JSIConverter<std::string>::toJSI(runtime, "tablet");
        case margelo::nitro::healthkit::GeneralForm::TOPICAL: return JSIConverter<std::string>::toJSI(runtime, "topical");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert GeneralForm 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("device"):
        case hashString("unknown"):
        case hashString("capsule"):
        case hashString("cream"):
        case hashString("drops"):
        case hashString("foam"):
        case hashString("gel"):
        case hashString("inhaler"):
        case hashString("injection"):
        case hashString("liquid"):
        case hashString("lotion"):
        case hashString("ointment"):
        case hashString("patch"):
        case hashString("powder"):
        case hashString("spray"):
        case hashString("suppository"):
        case hashString("tablet"):
        case hashString("topical"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
