///
/// SecureStoreAccessibility.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::one {

  /**
   * An enum which can be represented as a JavaScript union (SecureStoreAccessibility).
   */
  enum class SecureStoreAccessibility {
    ALWAYS      SWIFT_NAME(always) = 0,
    AFTERFIRSTUNLOCK      SWIFT_NAME(afterfirstunlock) = 1,
    AFTERFIRSTUNLOCKTHISDEVICEONLY      SWIFT_NAME(afterfirstunlockthisdeviceonly) = 2,
    ALWAYSTHISDEVICEONLY      SWIFT_NAME(alwaysthisdeviceonly) = 3,
    WHENPASSCODESETTHISDEVICEONLY      SWIFT_NAME(whenpasscodesetthisdeviceonly) = 4,
    WHENUNLOCKED      SWIFT_NAME(whenunlocked) = 5,
    WHENUNLOCKEDTHISDEVICEONLY      SWIFT_NAME(whenunlockedthisdeviceonly) = 6,
  } CLOSED_ENUM;

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ SecureStoreAccessibility <> JS SecureStoreAccessibility (union)
  template <>
  struct JSIConverter<margelo::nitro::one::SecureStoreAccessibility> final {
    static inline margelo::nitro::one::SecureStoreAccessibility 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("always"): return margelo::nitro::one::SecureStoreAccessibility::ALWAYS;
        case hashString("afterFirstUnlock"): return margelo::nitro::one::SecureStoreAccessibility::AFTERFIRSTUNLOCK;
        case hashString("afterFirstUnlockThisDeviceOnly"): return margelo::nitro::one::SecureStoreAccessibility::AFTERFIRSTUNLOCKTHISDEVICEONLY;
        case hashString("alwaysThisDeviceOnly"): return margelo::nitro::one::SecureStoreAccessibility::ALWAYSTHISDEVICEONLY;
        case hashString("whenPasscodeSetThisDeviceOnly"): return margelo::nitro::one::SecureStoreAccessibility::WHENPASSCODESETTHISDEVICEONLY;
        case hashString("whenUnlocked"): return margelo::nitro::one::SecureStoreAccessibility::WHENUNLOCKED;
        case hashString("whenUnlockedThisDeviceOnly"): return margelo::nitro::one::SecureStoreAccessibility::WHENUNLOCKEDTHISDEVICEONLY;
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SecureStoreAccessibility - invalid value!");
      }
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::one::SecureStoreAccessibility arg) {
      switch (arg) {
        case margelo::nitro::one::SecureStoreAccessibility::ALWAYS: return JSIConverter<std::string>::toJSI(runtime, "always");
        case margelo::nitro::one::SecureStoreAccessibility::AFTERFIRSTUNLOCK: return JSIConverter<std::string>::toJSI(runtime, "afterFirstUnlock");
        case margelo::nitro::one::SecureStoreAccessibility::AFTERFIRSTUNLOCKTHISDEVICEONLY: return JSIConverter<std::string>::toJSI(runtime, "afterFirstUnlockThisDeviceOnly");
        case margelo::nitro::one::SecureStoreAccessibility::ALWAYSTHISDEVICEONLY: return JSIConverter<std::string>::toJSI(runtime, "alwaysThisDeviceOnly");
        case margelo::nitro::one::SecureStoreAccessibility::WHENPASSCODESETTHISDEVICEONLY: return JSIConverter<std::string>::toJSI(runtime, "whenPasscodeSetThisDeviceOnly");
        case margelo::nitro::one::SecureStoreAccessibility::WHENUNLOCKED: return JSIConverter<std::string>::toJSI(runtime, "whenUnlocked");
        case margelo::nitro::one::SecureStoreAccessibility::WHENUNLOCKEDTHISDEVICEONLY: return JSIConverter<std::string>::toJSI(runtime, "whenUnlockedThisDeviceOnly");
        default: [[unlikely]]
          throw std::invalid_argument("Cannot convert SecureStoreAccessibility 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("always"):
        case hashString("afterFirstUnlock"):
        case hashString("afterFirstUnlockThisDeviceOnly"):
        case hashString("alwaysThisDeviceOnly"):
        case hashString("whenPasscodeSetThisDeviceOnly"):
        case hashString("whenUnlocked"):
        case hashString("whenUnlockedThisDeviceOnly"):
          return true;
        default:
          return false;
      }
    }
  };

} // namespace margelo::nitro
