///
/// ImageTransformOptions.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 `ImageCrop` to properly resolve imports.
namespace margelo::nitro::one { struct ImageCrop; }
// Forward declaration of `ImageResize` to properly resolve imports.
namespace margelo::nitro::one { struct ImageResize; }
// Forward declaration of `OneImageFlip` to properly resolve imports.
namespace margelo::nitro::one { enum class OneImageFlip; }
// Forward declaration of `OneImageFormat` to properly resolve imports.
namespace margelo::nitro::one { enum class OneImageFormat; }

#include "ImageCrop.hpp"
#include <optional>
#include "ImageResize.hpp"
#include "OneImageFlip.hpp"
#include "OneImageFormat.hpp"

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (ImageTransformOptions).
   */
  struct ImageTransformOptions final {
  public:
    std::optional<ImageCrop> crop     SWIFT_PRIVATE;
    std::optional<ImageResize> resize     SWIFT_PRIVATE;
    std::optional<double> rotate     SWIFT_PRIVATE;
    std::optional<OneImageFlip> flip     SWIFT_PRIVATE;
    OneImageFormat format     SWIFT_PRIVATE;
    std::optional<double> quality     SWIFT_PRIVATE;

  public:
    ImageTransformOptions() = default;
    explicit ImageTransformOptions(std::optional<ImageCrop> crop, std::optional<ImageResize> resize, std::optional<double> rotate, std::optional<OneImageFlip> flip, OneImageFormat format, std::optional<double> quality): crop(crop), resize(resize), rotate(rotate), flip(flip), format(format), quality(quality) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

  // C++ ImageTransformOptions <> JS ImageTransformOptions (object)
  template <>
  struct JSIConverter<margelo::nitro::one::ImageTransformOptions> final {
    static inline margelo::nitro::one::ImageTransformOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::one::ImageTransformOptions(
        JSIConverter<std::optional<margelo::nitro::one::ImageCrop>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "crop"))),
        JSIConverter<std::optional<margelo::nitro::one::ImageResize>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resize"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rotate"))),
        JSIConverter<std::optional<margelo::nitro::one::OneImageFlip>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flip"))),
        JSIConverter<margelo::nitro::one::OneImageFormat>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "format"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::one::ImageTransformOptions& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "crop"), JSIConverter<std::optional<margelo::nitro::one::ImageCrop>>::toJSI(runtime, arg.crop));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "resize"), JSIConverter<std::optional<margelo::nitro::one::ImageResize>>::toJSI(runtime, arg.resize));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "rotate"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.rotate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "flip"), JSIConverter<std::optional<margelo::nitro::one::OneImageFlip>>::toJSI(runtime, arg.flip));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "format"), JSIConverter<margelo::nitro::one::OneImageFormat>::toJSI(runtime, arg.format));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "quality"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.quality));
      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::optional<margelo::nitro::one::ImageCrop>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "crop")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::one::ImageResize>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resize")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rotate")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::one::OneImageFlip>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "flip")))) return false;
      if (!JSIConverter<margelo::nitro::one::OneImageFormat>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "format")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
