#pragma once

#include "RSListCtrl.h"

namespace xtr::ui {

//! Control: RS Equations options table
class EquationsRSLC {
  struct EquationsHeader;

public:
  RSListCtrl control{};
  
public:
  void InitHeader();

public:
  struct Item {
    CString name1{};
    CString name2{};
    CString term1{};
    CString term2{};
    ccl::ops::Equation::Mode type{ ccl::ops::Equation::Mode::keepHier };
  };

  using Index = int32_t;
  Index InsertItem(const Item& input);
  [[nodiscard]] std::optional<Item> GetSelectedItem() const;
  [[nodiscard]] std::optional<Item> GetItem(Index nItem) const;

  void LoadTableSynth(const ccl::ops::EquationOptions& aMap,
                      const ccl::semantic::RSForm& ks1, 
                      const ccl::semantic::RSForm& ks2);
  [[nodiscard]] std::optional<ccl::ops::EquationOptions>
    CreateEquations(const ccl::semantic::RSForm& schema1, const ccl::semantic::RSForm& schema2) const;

  [[nodiscard]] ccl::SetOfEntities Inputs(const ccl::semantic::RSForm& ks1) const;
  [[nodiscard]] ccl::SetOfEntities Outputs(const ccl::semantic::RSForm& ks2) const;

private:
  [[nodiscard]] static ccl::ops::Equation::Mode Str2Type(CString str) noexcept;
  [[nodiscard]] static CString Type2Str(ccl::ops::Equation::Mode type);
};

//! Control: Constituent picker ComboBox
class CstPicker : public CComboBox {
public:
  enum class Mode : uint8_t {
    TITLE = 1,
    ALIAS,
    DEFAULT,
  };

private:
  Mode menuMode{ Mode::DEFAULT };
  CString m_Exclude{};

public:
  uint32_t Init(Mode mode = Mode::TITLE, CString exclude = {});
  [[nodiscard]] BOOL IsValid() const;

private:
  void UpdateList();
};

} // namespace xtr::ui