#ifndef BOTTASK_H
#define BOTTASK_H
#include <memory>
#include <string>

#include "ExecutableTask.h"
#include "isxeq2/LSObject.h"

class BotTask final : public ExecutableTask, public std::enable_shared_from_this<BotTask> {
public:
    static std::shared_ptr<BotTask> Instance();

    ~BotTask() override;

    void Execute() override;

    void Close();

    void ToggleBot();

    void ToggleSettings();

    [[nodiscard]] TaskTypeEnum TaskType() const override;

private:
    BotTask();

    static std::weak_ptr<BotTask> instance;

    const std::string ScriptName = "MRBot";
    const std::string OnClosedEventName = "MRBot_OnCloseButtonClicked";
    const std::string ToggleBotEventName = "MRBot_OnToggleBotButtonClicked";
    const std::string ToggleSettingsEventName = "MRBot_OnSettingsButtonClicked";

    std::shared_ptr<LSObject> botController;
    std::shared_ptr<LSObject> settingsController;

    u_int onCloseButtonClickedEventId = 0;
    u_int onToggleBotButtonClickedEventId = 0;
    u_int onToggleSettingsButtonClickedEventId = 0;
    bool isBotRunning = false;

    static void __cdecl OnCloseEventHandler(int argc, char *argv[], PLSOBJECT plsObject);

    static void __cdecl OnToggleBotEventHandler(int argc, char *argv[], PLSOBJECT plsObject);

    static void __cdecl OnToggleSettingsEventHandler(int argc, char *argv[], PLSOBJECT plsObject);
};

#endif //BOTTASK_H
