///
/// HybridThorViewComponent.hpp
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
/// https://github.com/mrousavy/nitro
/// Copyright © Marc Rousavy @ Margelo
///

#pragma once

#include <optional>
#include <NitroModules/NitroDefines.hpp>
#include <NitroModules/NitroHash.hpp>
#include <NitroModules/CachedProp.hpp>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <react/renderer/components/view/ViewProps.h>

#include "ThorShape.hpp"
#include <vector>
#include "ThorBackend.hpp"
#include <optional>
#include <memory>
#include "HybridThorViewSpec.hpp"
#include <functional>

namespace margelo::nitro::thor::views {

  using namespace facebook;

  /**
   * The name of the actual native View.
   */
  extern const char HybridThorViewComponentName[];

  /**
   * Props for the "ThorView" View.
   */
  class HybridThorViewProps final: public react::ViewProps {
  public:
    HybridThorViewProps() = default;
    HybridThorViewProps(const react::PropsParserContext& context,
                        const HybridThorViewProps& sourceProps,
                        const react::RawProps& rawProps);

  public:
    CachedProp<std::vector<ThorShape>> shapes;
    CachedProp<std::optional<ThorBackend>> backend;
    CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridThorViewSpec>& /* ref */)>>> hybridRef;

  private:
    static bool filterObjectKeys(const std::string& propName);
  };

  /**
   * State for the "ThorView" View.
   */
  class HybridThorViewState final {
  public:
    HybridThorViewState() = default;
    explicit HybridThorViewState(const std::shared_ptr<HybridThorViewProps>& props):
      _props(props) {}

  public:
    [[nodiscard]]
    const std::shared_ptr<HybridThorViewProps>& getProps() const {
      return _props;
    }

  public:
#ifdef ANDROID
  HybridThorViewState(const HybridThorViewState& /* previousState */, folly::dynamic /* data */) {}
  folly::dynamic getDynamic() const {
    throw std::runtime_error("HybridThorViewState does not support folly!");
  }
  react::MapBuffer getMapBuffer() const {
    throw std::runtime_error("HybridThorViewState does not support MapBuffer!");
  };
#endif

  private:
    std::shared_ptr<HybridThorViewProps> _props;
  };

  /**
   * The Shadow Node for the "ThorView" View.
   */
  using HybridThorViewShadowNode = react::ConcreteViewShadowNode<HybridThorViewComponentName /* "HybridThorView" */,
                                                                 HybridThorViewProps /* custom props */,
                                                                 react::ViewEventEmitter /* default */,
                                                                 HybridThorViewState /* custom state */>;

  /**
   * The Component Descriptor for the "ThorView" View.
   */
  class HybridThorViewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridThorViewShadowNode> {
  public:
    explicit HybridThorViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);

  public:
    /**
     * A faster path for cloning props - reuses the caching logic from `HybridThorViewProps`.
     */
    std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
                                                   const std::shared_ptr<const react::Props>& props,
                                                   react::RawProps rawProps) const override;
#ifdef ANDROID
    void adopt(react::ShadowNode& shadowNode) const override;
#endif
  };

  /* The actual view for "ThorView" needs to be implemented in platform-specific code. */

} // namespace margelo::nitro::thor::views
