/*
 * Mirai. Copyright (C) 2024 Vyn
 * This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
 * The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
 */

#pragma once
#include "Mirai.h"
#include "Task.h"
#include <algorithm>
#include <iterator>
#include <map>
#include <memory>
#include <string>
#include <vector>

namespace mirai
{

struct DateView {
	std::vector<Task> tasks;
	std::vector<Event> events;
};

class View
{

  public:
	View(Mirai *mirai);

	void hideCompletedTasks(bool hide);
	bool shouldHideCompletedTasks() const;

	std::vector<Date> getDates();

	std::vector<Task> getTasksForDate(const Date &date);
	std::vector<Event> getEventsForDate(const Date &date);
	std::vector<Task> getUnscheduledTasks();

	void update();

	void removeSources();
	void addSource(const Source &source);
	void setSources(const std::vector<Source> &sources);
	void setAllSources();
	bool isSourceSelected(const Source &source) const;

	size_t activeSourceCount() const;

  private:
	Mirai *mirai_;
	std::vector<int> sourcesIds_;
	std::vector<Task> unscheduledTasks_;
	std::map<Date, DateView> dates;

	bool shouldHideCompletedTasks_ = true;
};
} // namespace mirai
