#pragma once
#include <string>
#include <vector>

int globalNodeIdCounter = 0;

class NodeElement {
public:
	int id = -1;
	std::string name = {};
	ImVec2 position = {};

	NodeElement(std::string name);
};

class NodeWindow {
public:
	std::string title = {};
	std::vector<NodeElement> alerts = {};
	std::vector<NodeElement> triggers = {};

	NodeWindow(std::string title);
};

struct NodeConnection {
	int sourceID = -1;
	int targetID = -1;
};

struct ConnectionPayload {
	int sourceID = -1;
};

class ApplicationData {
public:
	std::vector<NodeWindow> nodes = {};
	std::vector<NodeConnection> connections = {};

	void addConnection(int sourceID, int targetID);
};

enum class CircleDragType
{
	None,
	Source,
	Target
};

void init(DrawData& drawData, ApplicationData& customData);
void draw(DrawData& drawData, ApplicationData& customDataVoid);

void invisibleDragArea(const void* id, ImVec2& size);
void drawCircle(ImVec2* outCircleCenter);
bool inlineButton(const char* title, const void* id);
bool invisibleInlineButton(const char* title, const char* id);
std::vector<NodeElement>::iterator cleanEraseElement(std::vector<NodeElement>& vector, std::vector<NodeElement>::iterator toErase, ApplicationData& data);
void cleanEreaseNodeElements(NodeWindow& node, ApplicationData& data);
