///
/// SecurityAvailability.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/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
#if __has_include(<NitroModules/JSIHelpers.hpp>)
#include <NitroModules/JSIHelpers.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
#include <NitroModules/PropNameIDCache.hpp>
#else
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
#endif

// Forward declaration of `BiometryStatus` to properly resolve imports.
namespace margelo::nitro::sensitiveinfo { enum class BiometryStatus; }

#include "BiometryStatus.hpp"

namespace margelo::nitro::sensitiveinfo {

  /**
   * A struct which can be represented as a JavaScript object (SecurityAvailability).
   */
  struct SecurityAvailability final {
  public:
    bool secureEnclave     SWIFT_PRIVATE;
    bool strongBox     SWIFT_PRIVATE;
    bool biometry     SWIFT_PRIVATE;
    BiometryStatus biometryStatus     SWIFT_PRIVATE;
    bool deviceCredential     SWIFT_PRIVATE;

  public:
    SecurityAvailability() = default;
    explicit SecurityAvailability(bool secureEnclave, bool strongBox, bool biometry, BiometryStatus biometryStatus, bool deviceCredential): secureEnclave(secureEnclave), strongBox(strongBox), biometry(biometry), biometryStatus(biometryStatus), deviceCredential(deviceCredential) {}

  public:
    friend bool operator==(const SecurityAvailability& lhs, const SecurityAvailability& rhs) = default;
  };

} // namespace margelo::nitro::sensitiveinfo

namespace margelo::nitro {

  // C++ SecurityAvailability <> JS SecurityAvailability (object)
  template <>
  struct JSIConverter<margelo::nitro::sensitiveinfo::SecurityAvailability> final {
    static inline margelo::nitro::sensitiveinfo::SecurityAvailability fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::sensitiveinfo::SecurityAvailability(
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "secureEnclave"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "strongBox"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "biometry"))),
        JSIConverter<margelo::nitro::sensitiveinfo::BiometryStatus>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "biometryStatus"))),
        JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceCredential")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::sensitiveinfo::SecurityAvailability& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "secureEnclave"), JSIConverter<bool>::toJSI(runtime, arg.secureEnclave));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "strongBox"), JSIConverter<bool>::toJSI(runtime, arg.strongBox));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "biometry"), JSIConverter<bool>::toJSI(runtime, arg.biometry));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "biometryStatus"), JSIConverter<margelo::nitro::sensitiveinfo::BiometryStatus>::toJSI(runtime, arg.biometryStatus));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "deviceCredential"), JSIConverter<bool>::toJSI(runtime, arg.deviceCredential));
      return obj;
    }
    static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
      if (!value.isObject()) {
        return false;
      }
      jsi::Object obj = value.getObject(runtime);
      if (!nitro::isPlainObject(runtime, obj)) {
        return false;
      }
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "secureEnclave")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "strongBox")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "biometry")))) return false;
      if (!JSIConverter<margelo::nitro::sensitiveinfo::BiometryStatus>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "biometryStatus")))) return false;
      if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "deviceCredential")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
