///
/// HybridViewHolderComponent.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 <memory>
#include "HybridViewHolderSpec.hpp"
#include <functional>
#include <optional>

namespace margelo::nitro::reactnativelist::views {

  using namespace facebook;

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

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

  public:
    CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridViewHolderSpec>& /* ref */)>>> hybridRef;

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

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

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

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

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

  /**
   * The Shadow Node for the "ViewHolder" View.
   */
  using HybridViewHolderShadowNode = react::ConcreteViewShadowNode<HybridViewHolderComponentName /* "HybridViewHolder" */,
                                                                   HybridViewHolderProps /* custom props */,
                                                                   react::ViewEventEmitter /* default */,
                                                                   HybridViewHolderState /* custom state */>;

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

  public:
    /**
     * A faster path for cloning props - reuses the caching logic from `HybridViewHolderProps`.
     */
    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 "ViewHolder" needs to be implemented in platform-specific code. */

} // namespace margelo::nitro::reactnativelist::views
