///
/// ImagePickerAsset.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 `ImagePickerAssetType` to properly resolve imports.
namespace margelo::nitro::one { enum class ImagePickerAssetType; }

#include <string>
#include <optional>
#include "ImagePickerAssetType.hpp"

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (ImagePickerAsset).
   */
  struct ImagePickerAsset final {
  public:
    std::string uri     SWIFT_PRIVATE;
    double width     SWIFT_PRIVATE;
    double height     SWIFT_PRIVATE;
    std::optional<std::string> mimeType     SWIFT_PRIVATE;
    std::optional<std::string> fileName     SWIFT_PRIVATE;
    std::optional<double> fileSize     SWIFT_PRIVATE;
    std::optional<double> duration     SWIFT_PRIVATE;
    std::optional<ImagePickerAssetType> type     SWIFT_PRIVATE;

  public:
    ImagePickerAsset() = default;
    explicit ImagePickerAsset(std::string uri, double width, double height, std::optional<std::string> mimeType, std::optional<std::string> fileName, std::optional<double> fileSize, std::optional<double> duration, std::optional<ImagePickerAssetType> type): uri(uri), width(width), height(height), mimeType(mimeType), fileName(fileName), fileSize(fileSize), duration(duration), type(type) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ ImagePickerAsset <> JS ImagePickerAsset (object)
  template <>
  struct JSIConverter<margelo::nitro::one::ImagePickerAsset> final {
    static inline margelo::nitro::one::ImagePickerAsset fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::ImagePickerAsset(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
        JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileName"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileSize"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration"))),
        JSIConverter<std::optional<margelo::nitro::one::ImagePickerAssetType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::ImagePickerAsset& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "uri"), JSIConverter<std::string>::toJSI(runtime, arg.uri));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<double>::toJSI(runtime, arg.width));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<double>::toJSI(runtime, arg.height));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "mimeType"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.mimeType));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "fileName"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.fileName));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "fileSize"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.fileSize));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "duration"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.duration));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<std::optional<margelo::nitro::one::ImagePickerAssetType>>::toJSI(runtime, arg.type));
      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<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "uri")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
      if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "mimeType")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileName")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fileSize")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "duration")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::one::ImagePickerAssetType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
