///
/// LDP_Range.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © 2025 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



#include <string>
#include <optional>

namespace margelo::nitro::lunardatepicker {

  /**
   * A struct which can be represented as a JavaScript object (LDP_Range).
   */
  struct LDP_Range {
  public:
    std::string from     SWIFT_PRIVATE;
    std::optional<std::string> to     SWIFT_PRIVATE;

  public:
    LDP_Range() = default;
    explicit LDP_Range(std::string from, std::optional<std::string> to): from(from), to(to) {}
  };

} // namespace margelo::nitro::lunardatepicker

namespace margelo::nitro {

  using namespace margelo::nitro::lunardatepicker;

  // C++ LDP_Range <> JS LDP_Range (object)
  template <>
  struct JSIConverter<LDP_Range> final {
    static inline LDP_Range fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
      jsi::Object obj = arg.asObject(runtime);
      return LDP_Range(
        JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "from")),
        JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "to"))
      );
    }
    static inline jsi::Value toJSI(jsi::Runtime& runtime, const LDP_Range& arg) {
      jsi::Object obj(runtime);
      obj.setProperty(runtime, "from", JSIConverter<std::string>::toJSI(runtime, arg.from));
      obj.setProperty(runtime, "to", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.to));
      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 (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "from"))) return false;
      if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "to"))) return false;
      return true;
    }
  };

} // namespace margelo::nitro
