// D:\Dev\Mosis\MosisService\designer\src\testing\action_types.h
#pragma once

#include <string>
#include <vector>
#include <variant>
#include <cstdint>

namespace mosis::testing {

// Action types that can be recorded and played back
struct TapAction {
    int x;
    int y;
    int64_t timestamp_ms;
};

struct SwipeAction {
    int x1, y1;
    int x2, y2;
    int duration_ms;
    int64_t timestamp_ms;
};

struct LongPressAction {
    int x;
    int y;
    int duration_ms;
    int64_t timestamp_ms;
};

struct ButtonAction {
    std::string button;  // "back", "home", "recents"
    int64_t timestamp_ms;
};

struct WaitAction {
    int duration_ms;
    int64_t timestamp_ms;
};

struct KeyAction {
    int key_code;
    bool pressed;  // true = down, false = up
    int64_t timestamp_ms;
};

// Variant holding any action type
using Action = std::variant<TapAction, SwipeAction, LongPressAction, ButtonAction, WaitAction, KeyAction>;

// Get action type name
inline std::string GetActionTypeName(const Action& action) {
    return std::visit([](auto&& arg) -> std::string {
        using T = std::decay_t<decltype(arg)>;
        if constexpr (std::is_same_v<T, TapAction>) return "tap";
        else if constexpr (std::is_same_v<T, SwipeAction>) return "swipe";
        else if constexpr (std::is_same_v<T, LongPressAction>) return "long_press";
        else if constexpr (std::is_same_v<T, ButtonAction>) return "button";
        else if constexpr (std::is_same_v<T, WaitAction>) return "wait";
        else if constexpr (std::is_same_v<T, KeyAction>) return "key";
        else return "unknown";
    }, action);
}

// Get action timestamp
inline int64_t GetActionTimestamp(const Action& action) {
    return std::visit([](auto&& arg) -> int64_t {
        return arg.timestamp_ms;
    }, action);
}

// Recording session
struct ActionSequence {
    std::string name;
    std::string description;
    int screen_width;
    int screen_height;
    std::string initial_screen;
    std::vector<Action> actions;
};

} // namespace mosis::testing
