///
/// GeneratePreviewOptions.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



#include <optional>
#include <string>

namespace margelo::nitro::mediatoolkit {

  /**
   * A struct which can be represented as a JavaScript object (GeneratePreviewOptions).
   */
  struct GeneratePreviewOptions final {
  public:
    std::optional<double> fps     SWIFT_PRIVATE;
    std::optional<double> durationMs     SWIFT_PRIVATE;
    std::optional<double> maxWidth     SWIFT_PRIVATE;
    std::optional<double> quality     SWIFT_PRIVATE;
    std::optional<std::string> outputPath     SWIFT_PRIVATE;

  public:
    GeneratePreviewOptions() = default;
    explicit GeneratePreviewOptions(std::optional<double> fps, std::optional<double> durationMs, std::optional<double> maxWidth, std::optional<double> quality, std::optional<std::string> outputPath): fps(fps), durationMs(durationMs), maxWidth(maxWidth), quality(quality), outputPath(outputPath) {}

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

} // namespace margelo::nitro::mediatoolkit

namespace margelo::nitro {

  // C++ GeneratePreviewOptions <> JS GeneratePreviewOptions (object)
  template <>
  struct JSIConverter<margelo::nitro::mediatoolkit::GeneratePreviewOptions> final {
    static inline margelo::nitro::mediatoolkit::GeneratePreviewOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::mediatoolkit::GeneratePreviewOptions(
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fps"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxWidth"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputPath")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::mediatoolkit::GeneratePreviewOptions& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "fps"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.fps));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "durationMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.durationMs));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "maxWidth"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.maxWidth));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "quality"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.quality));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "outputPath"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.outputPath));
      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<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fps")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "durationMs")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "maxWidth")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "quality")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outputPath")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
