///
/// MetadataSpec.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 `WGS84Coordinate` to properly resolve imports.
namespace margelo::nitro::videopipeline { struct WGS84Coordinate; }

#include "WGS84Coordinate.hpp"
#include <optional>
#include <string>
#include <chrono>
#include <unordered_map>

namespace margelo::nitro::videopipeline {

  /**
   * A struct which can be represented as a JavaScript object (MetadataSpec).
   */
  struct MetadataSpec final {
  public:
    std::optional<WGS84Coordinate> location     SWIFT_PRIVATE;
    std::optional<std::string> software     SWIFT_PRIVATE;
    std::optional<std::chrono::system_clock::time_point> creationDate     SWIFT_PRIVATE;
    std::optional<std::string> description     SWIFT_PRIVATE;
    std::optional<std::unordered_map<std::string, std::string>> custom     SWIFT_PRIVATE;

  public:
    MetadataSpec() = default;
    explicit MetadataSpec(std::optional<WGS84Coordinate> location, std::optional<std::string> software, std::optional<std::chrono::system_clock::time_point> creationDate, std::optional<std::string> description, std::optional<std::unordered_map<std::string, std::string>> custom): location(location), software(software), creationDate(creationDate), description(description), custom(custom) {}

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

} // namespace margelo::nitro::videopipeline

namespace margelo::nitro {

  // C++ MetadataSpec <> JS MetadataSpec (object)
  template <>
  struct JSIConverter<margelo::nitro::videopipeline::MetadataSpec> final {
    static inline margelo::nitro::videopipeline::MetadataSpec fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return margelo::nitro::videopipeline::MetadataSpec(
        JSIConverter<std::optional<margelo::nitro::videopipeline::WGS84Coordinate>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "location"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "software"))),
        JSIConverter<std::optional<std::chrono::system_clock::time_point>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "creationDate"))),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "description"))),
        JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "custom")))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::videopipeline::MetadataSpec& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "location"), JSIConverter<std::optional<margelo::nitro::videopipeline::WGS84Coordinate>>::toJSI(runtime, arg.location));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "software"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.software));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "creationDate"), JSIConverter<std::optional<std::chrono::system_clock::time_point>>::toJSI(runtime, arg.creationDate));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "description"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.description));
      obj.setProperty(runtime, PropNameIDCache::get(runtime, "custom"), JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::toJSI(runtime, arg.custom));
      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::videopipeline::WGS84Coordinate>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "location")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "software")))) return false;
      if (!JSIConverter<std::optional<std::chrono::system_clock::time_point>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "creationDate")))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "description")))) return false;
      if (!JSIConverter<std::optional<std::unordered_map<std::string, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "custom")))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
