#pragma once

#include <cstdint>
#include <string>

#include "display/ui/home/home_model.h"
#include "display/ui/home/home_view.h"

namespace hwdisplay::ui {

// Converts camera observations into stable HomeModel updates. This page does
// not navigate yet; a future page coordinator can use presence() to start the
// guided sequence without changing HomeView.
class HomeController {
public:
    bool Create(lv_obj_t* parent);
    void Update(int face_count, int hand_count, const std::string& known_name, uint64_t now_ms,
                bool camera_online = true);
    void SetFaceFrameBuffer(uint8_t* pixels, size_t bytes) { view_.SetFaceFrameBuffer(pixels, bytes); }
    void ShowFaceFrame(const uint8_t* bgra, size_t bytes) { view_.ShowFaceFrame(bgra, bytes); }
    void Destroy();

    HomePresence presence() const { return model_.presence; }

private:
    HomeModel model_{};
    HomeView view_;
    HomePresence pending_ = HomePresence::Waiting;
    std::string pending_name_;
    uint64_t pending_since_ms_ = 0;
    bool pending_valid_ = false;
};

}  // namespace hwdisplay::ui
