/*
    * usermanager_internal.hpp
    * Shared declarations for the embedded desktop user management applet
    * Copyright (c) 2026 Daniel Hammer
*/

#pragma once

#include "../apps_common.hpp"
#include <gui/mtk.hpp>
#include <montauk/user.h>

namespace usermanager_app {

struct UserManagerState {
    DesktopState* desktop;
    montauk::user::UserInfo users[16];
    int user_count;
    int selected_user;
    bool users_loaded;
    char status_msg[128];
    uint64_t status_time;
    int mouse_x;
    int mouse_y;
};

inline constexpr int USER_BTN_H = 30;
inline constexpr int USER_BTN_W = 100;
inline constexpr int USER_FIELD_H = 32;

inline mtk::Theme usermanager_theme(const UserManagerState* st) {
    return mtk::make_theme(st->desktop->settings.accent_color);
}

bool usermanager_status_visible(UserManagerState* st);
void usermanager_set_status(UserManagerState* st, const char* msg);
void usermanager_reload(UserManagerState* st);
int user_row_height();
void usermanager_update_mouse(UserManagerState* st, int mx, int my);

void usermanager_draw(Canvas& c, UserManagerState* st);
bool usermanager_handle_click(Window* win, UserManagerState* st, int mx, int my);

void open_add_user_dialog(UserManagerState* parent);
void open_change_pwd_dialog(UserManagerState* parent);
void open_delete_user_dialog(UserManagerState* parent);

} // namespace usermanager_app
