///
/// CalendarInfo.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 <string>
#include <optional>

namespace margelo::nitro::one {

  /**
   * A struct which can be represented as a JavaScript object (CalendarInfo).
   */
  struct CalendarInfo final {
  public:
    std::optional<std::string> calendar     SWIFT_PRIVATE;
    std::optional<std::string> timeZone     SWIFT_PRIVATE;
    std::optional<bool> uses24hourClock     SWIFT_PRIVATE;
    std::optional<double> firstWeekday     SWIFT_PRIVATE;

  public:
    CalendarInfo() = default;
    explicit CalendarInfo(std::optional<std::string> calendar, std::optional<std::string> timeZone, std::optional<bool> uses24hourClock, std::optional<double> firstWeekday): calendar(calendar), timeZone(timeZone), uses24hourClock(uses24hourClock), firstWeekday(firstWeekday) {}

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

} // namespace margelo::nitro::one

namespace margelo::nitro {

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

} // namespace margelo::nitro
