#pragma once

#include <string>
#include <vector>

#include <imgui.h>

#include "application/contracts/IKeyInput.h"

namespace ta::presentation::widgets
{
    struct TwoColumnLayout
    {
        float gap = 0.0f;
        float width = 0.0f;
        float height = 0.0f;
        bool stacked = false;
    };

    [[nodiscard]] TwoColumnLayout two_column_layout(float minimum_column_width_unscaled = 200.0f);
    [[nodiscard]] bool compact_layout(float minimum_width_unscaled = 200.0f);

    bool begin_field_row(const std::string& label);
    void end_field_row();

    bool action_button(const std::string& label,
                       float max_width_unscaled = 180.0f,
                       float min_width_unscaled = 72.0f);
    bool toggle_button(const std::string& id, bool* value, float width_unscaled = 92.0f);

    void section_header(const std::string& title, bool separator = true);
    void empty_state(const char* title_key, const char* hint_key = nullptr);

    void centered_text(ImDrawList* draw_list,
                       const ImVec2& pos,
                       ImVec4 color,
                       const std::string& text,
                       ImFont* font = nullptr,
                       float font_size = 0.0f);

    bool select(const std::string& label, int* value, const std::vector<std::string>& options);
    bool keybind(const std::string& label, int* virtual_key, bool allow_none, ta::application::IKeyInput& input);
    bool slider_float(const std::string& label, float* value, float min, float max, float step = 0.1f);
    bool slider_int(const std::string& label, int* value, int min, int max);
    bool colorpicker(const std::string& label, float* rgba);
    bool compact_colorpicker(const std::string& label, float* rgba);
    bool int_textbox(const std::string& label, int* value);
    bool textbox(const std::string& label, std::string* value);
    bool checkbox(const std::string& label, bool* value);
    [[nodiscard]] bool is_keybind_capturing() noexcept;

    void hint_text(const char* text);
    void warning_text(const char* text);
}
