#pragma once

#include <memory>
#include <vector>
#include "lumacs/window.hpp" // For Window class
#include "lumacs/buffer.hpp" // For shared_ptr<Buffer> (indirectly via Window)

namespace lumacs {

// Forward declaration
class Window;

/// @brief Represents a node in the window layout tree.
/// Can be a leaf node (holding a Window) or an internal node (representing a split).
struct LayoutNode {
    enum class Type {
        Leaf,
        HorizontalSplit, // Children are top/bottom
        VerticalSplit    // Children are left/right
    };

    Type type;
    std::shared_ptr<Window> window; // Valid if type is Leaf
    std::shared_ptr<LayoutNode> child1; // Valid if type is Horizontal/VerticalSplit
    std::shared_ptr<LayoutNode> child2; // Valid if type is Horizontal/VerticalSplit
    double ratio = 0.5; // Ratio for split (e.g., 0.5 for a 50/50 split)

    // Constructor for leaf nodes (a window)
    explicit LayoutNode(std::shared_ptr<Window> win)
        : type(Type::Leaf), window(std::move(win)) {}

    // Constructor for internal nodes (a split)
    LayoutNode(Type t, std::shared_ptr<LayoutNode> c1, std::shared_ptr<LayoutNode> c2)
        : type(t), child1(std::move(c1)), child2(std::move(c2)) {}
};

} // namespace lumacs
