///
/// OutputSpec.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 `VideoCodec` to properly resolve imports.
namespace margelo::nitro::videopipeline { enum class VideoCodec; }
// Forward declaration of `VideoContainer` to properly resolve imports.
namespace margelo::nitro::videopipeline { enum class VideoContainer; }
// Forward declaration of `ColorRange` to properly resolve imports.
namespace margelo::nitro::videopipeline { enum class ColorRange; }

#include <string>
#include <optional>
#include "VideoCodec.hpp"
#include "VideoContainer.hpp"
#include "ColorRange.hpp"

namespace margelo::nitro::videopipeline {

  /**
   * A struct which can be represented as a JavaScript object (OutputSpec).
   */
  struct OutputSpec final {
  public:
    std::string path     SWIFT_PRIVATE;
    std::optional<double> width     SWIFT_PRIVATE;
    std::optional<double> height     SWIFT_PRIVATE;
    std::optional<double> fps     SWIFT_PRIVATE;
    std::optional<double> bitrate     SWIFT_PRIVATE;
    std::optional<VideoCodec> codec     SWIFT_PRIVATE;
    std::optional<VideoContainer> container     SWIFT_PRIVATE;
    std::optional<ColorRange> colorRange     SWIFT_PRIVATE;

  public:
    OutputSpec() = default;
    explicit OutputSpec(std::string path, std::optional<double> width, std::optional<double> height, std::optional<double> fps, std::optional<double> bitrate, std::optional<VideoCodec> codec, std::optional<VideoContainer> container, std::optional<ColorRange> colorRange): path(path), width(width), height(height), fps(fps), bitrate(bitrate), codec(codec), container(container), colorRange(colorRange) {}

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

} // namespace margelo::nitro::videopipeline

namespace margelo::nitro {

  // C++ OutputSpec <> JS OutputSpec (object)
  template <>
  struct JSIConverter<margelo::nitro::videopipeline::OutputSpec> final {
    static inline margelo::nitro::videopipeline::OutputSpec fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::videopipeline::OutputSpec(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "path"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width"))),
        JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height"))),
        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, "bitrate"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::VideoCodec>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "codec"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::VideoContainer>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "container"))),
        JSIConverter<std::optional<margelo::nitro::videopipeline::ColorRange>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorRange")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::videopipeline::OutputSpec& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "path"), JSIConverter<std::string>::toJSI(runtime, arg.path));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "width"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.width));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "height"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.height));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "fps"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.fps));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "bitrate"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.bitrate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "codec"), JSIConverter<std::optional<margelo::nitro::videopipeline::VideoCodec>>::toJSI(runtime, arg.codec));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "container"), JSIConverter<std::optional<margelo::nitro::videopipeline::VideoContainer>>::toJSI(runtime, arg.container));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "colorRange"), JSIConverter<std::optional<margelo::nitro::videopipeline::ColorRange>>::toJSI(runtime, arg.colorRange));
      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, "path")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "width")))) return false;
      if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "height")))) 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, "bitrate")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::VideoCodec>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "codec")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::VideoContainer>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "container")))) return false;
      if (!JSIConverter<std::optional<margelo::nitro::videopipeline::ColorRange>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "colorRange")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
