/* stats-week-page.c generated by valac 0.56.19, the Vala compiler
 * generated from stats-week-page.vala, do not modify */

/*
 * Copyright (c) 2017-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_ui.h"
#include <glib.h>
#include "ft_core.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <float.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include <gio/gio.h>
#include <gom/gom.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	FT_STATS_WEEK_PAGE_0_PROPERTY,
	FT_STATS_WEEK_PAGE_DATE_PROPERTY,
	FT_STATS_WEEK_PAGE_NUM_PROPERTIES
};
static GParamSpec* ft_stats_week_page_properties[FT_STATS_WEEK_PAGE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _FtStatsWeekPageFetchAggregatedEntriesData FtStatsWeekPageFetchAggregatedEntriesData;
typedef struct _FtStatsWeekPagePopulateData FtStatsWeekPagePopulateData;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FtStatsWeekPagePrivate {
	GDate _date;
	FtBarChart* histogram;
	FtStatsCard* pomodoro_card;
	FtStatsCard* breaks_card;
	FtStatsCard* interruptions_card;
	FtStatsCard* break_ratio_card;
	FtStatsManager* stats_manager;
	GDate start_date;
	GDate end_date;
};

struct _FtStatsWeekPageFetchAggregatedEntriesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtStatsWeekPage* self;
	GomResourceGroup* result;
	GomRepository* repository;
	GomRepository* _tmp0_;
	GomRepository* _tmp1_;
	GValue start_date_value;
	GValue _tmp2_;
	GDate _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GValue end_date_value;
	GValue _tmp6_;
	GDate _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GomFilter* start_date_filter;
	GValue _tmp10_;
	GomFilter* _tmp11_;
	GomFilter* end_date_filter;
	GValue _tmp12_;
	GomFilter* _tmp13_;
	GomFilter* date_filter;
	GomFilter* _tmp14_;
	GomFilter* _tmp15_;
	GomFilter* _tmp16_;
	GomResourceGroup* aggregated_entries;
	GomRepository* _tmp17_;
	GomFilter* _tmp18_;
	GomResourceGroup* _tmp19_;
	GomResourceGroup* _tmp20_;
	GomResourceGroup* _tmp21_;
	guint _tmp22_;
	guint _tmp23_;
	GError* _error_;
	GError* _tmp24_;
	const gchar* _tmp25_;
	GError* _inner_error0_;
};

struct _FtStatsWeekPagePopulateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtStatsWeekPage* self;
	GomResourceGroup* aggregated_entries;
	GomResourceGroup* _tmp0_;
	guint index;
	gboolean _tmp1_;
	guint _tmp2_;
	GomResourceGroup* _tmp3_;
	guint _tmp4_;
	guint _tmp5_;
	GomResourceGroup* _tmp6_;
	GomResource* _tmp7_;
};

static gint FtStatsWeekPage_private_offset;
static gpointer ft_stats_week_page_parent_class = NULL;
static FtStatsPageIface * ft_stats_week_page_ft_stats_page_parent_iface = NULL;

static gchar* ft_stats_week_page_format_hours (gdouble value);
static void ft_stats_week_page_transform_position (FtStatsWeekPage* self,
                                            guint bar_index,
                                            GDate* result);
static void ft_stats_week_page_reset (FtStatsWeekPage* self);
static void ft_stats_week_page_update_category_colors (FtStatsWeekPage* self);
VALA_EXTERN void ft_get_chart_primary_color (GdkRGBA* foreground_color,
                                 GdkRGBA* result);
VALA_EXTERN void ft_get_chart_secondary_color (GdkRGBA* foreground_color,
                                   GdkRGBA* result);
static void ft_stats_week_page_update_histogram_labels (FtStatsWeekPage* self);
VALA_EXTERN gchar* ft_capitalize_words (const gchar* text);
static void ft_stats_week_page_fetch_aggregated_entries_data_free (gpointer _data);
static void ft_stats_week_page_fetch_aggregated_entries (FtStatsWeekPage* self,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static GomResourceGroup* ft_stats_week_page_fetch_aggregated_entries_finish (FtStatsWeekPage* self,
                                                                      GAsyncResult* _res_);
static gboolean ft_stats_week_page_fetch_aggregated_entries_co (FtStatsWeekPageFetchAggregatedEntriesData* _data_);
static void ft_stats_week_page_fetch_aggregated_entries_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_);
static void ft_stats_week_page_process_aggregated_entry (FtStatsWeekPage* self,
                                                  FtAggregatedStatsEntry* entry);
static void ft_stats_week_page_process_entry (FtStatsWeekPage* self,
                                       FtStatsEntry* entry,
                                       gint sign);
static void ft_stats_week_page_populate_data_free (gpointer _data);
static void ft_stats_week_page_populate (FtStatsWeekPage* self,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_);
static void ft_stats_week_page_populate_finish (FtStatsWeekPage* self,
                                         GAsyncResult* _res_);
static gboolean ft_stats_week_page_populate_co (FtStatsWeekPagePopulateData* _data_);
static void ft_stats_week_page_populate_ready (GObject* source_object,
                                        GAsyncResult* _res_,
                                        gpointer _user_data_);
static void ft_stats_week_page_on_entry_saved (FtStatsWeekPage* self,
                                        FtStatsEntry* entry);
static void ft_stats_week_page_on_entry_deleted (FtStatsWeekPage* self,
                                          FtStatsEntry* entry);
static void ft_stats_week_page_on_bar_activated (FtStatsWeekPage* self,
                                          guint bar_index);
static void _ft_stats_week_page_on_bar_activated_ft_bar_chart_bar_activated (FtBarChart* _sender,
                                                                      guint bar_index,
                                                                      gpointer self);
static void ft_stats_week_page_real_css_changed (GtkWidget* base,
                                          GtkCssStyleChange* change);
static void ft_stats_week_page_real_dispose (GObject* base);
static void _ft_stats_week_page_on_entry_saved_ft_stats_manager_entry_saved (FtStatsManager* _sender,
                                                                      FtStatsEntry* entry,
                                                                      gpointer self);
static void _ft_stats_week_page_on_entry_deleted_ft_stats_manager_entry_deleted (FtStatsManager* _sender,
                                                                          FtStatsEntry* entry,
                                                                          gpointer self);
static gboolean _g_date_equal (const GDate * s1,
                        const GDate * s2);
static GObject * ft_stats_week_page_constructor (GType type,
                                          guint n_construct_properties,
                                          GObjectConstructParam * construct_properties);
static gchar* _ft_stats_week_page_format_hours_ft_format_value_func (gdouble value,
                                                              gpointer self);
static void _ft_stats_week_page___lambda30_ (FtStatsWeekPage* self,
                                      GObject* obj,
                                      GAsyncResult* res);
static void __ft_stats_week_page___lambda30__gasync_ready_callback (GObject* source_object,
                                                             GAsyncResult* res,
                                                             gpointer self);
static void ft_stats_week_page_finalize (GObject * obj);
static GType ft_stats_week_page_get_type_once (void);
static void _vala_ft_stats_week_page_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_ft_stats_week_page_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
ft_stats_week_page_get_instance_private (FtStatsWeekPage* self)
{
	return G_STRUCT_MEMBER_P (self, FtStatsWeekPage_private_offset);
}

FtStatsWeekPage*
ft_stats_week_page_construct (GType object_type,
                              GDate* date)
{
	FtStatsWeekPage * self = NULL;
	GDate _tmp0_;
	g_return_val_if_fail (date != NULL, NULL);
	_tmp0_ = *date;
	self = (FtStatsWeekPage*) g_object_new (object_type, "date", &_tmp0_, NULL);
	return self;
}

FtStatsWeekPage*
ft_stats_week_page_new (GDate* date)
{
	return ft_stats_week_page_construct (FT_TYPE_STATS_WEEK_PAGE, date);
}

static gchar*
ft_stats_week_page_format_hours (gdouble value)
{
	gchar* _tmp0_;
	gchar* result;
	_tmp0_ = ft_interval_format_short (ft_interval_from_seconds (value), FT_INTERVAL_HOUR);
	result = _tmp0_;
	return result;
}

static void
ft_stats_week_page_transform_position (FtStatsWeekPage* self,
                                       guint bar_index,
                                       GDate* result)
{
	GDate* date = NULL;
	GDate* _tmp0_;
	GDate* _tmp1_;
	GDate _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_date_copy (&self->priv->start_date);
	date = _tmp0_;
	g_date_add_days (date, bar_index);
	_tmp1_ = date;
	_tmp2_ = *_tmp1_;
	_g_free0 (_tmp1_);
	*result = _tmp2_;
	return;
}

static void
ft_stats_week_page_reset (FtStatsWeekPage* self)
{
	FtBarChart* _tmp0_;
	FtStatsCard* _tmp1_;
	FtStatsCard* _tmp2_;
	FtStatsCard* _tmp3_;
	FtStatsCard* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->histogram;
	ft_bar_chart_fill (_tmp0_, 0.0);
	_tmp1_ = self->priv->pomodoro_card;
	ft_stats_card_set_value (_tmp1_, 0.0);
	_tmp2_ = self->priv->breaks_card;
	ft_stats_card_set_value (_tmp2_, 0.0);
	_tmp3_ = self->priv->interruptions_card;
	ft_stats_card_set_value (_tmp3_, 0.0);
	_tmp4_ = self->priv->break_ratio_card;
	ft_stats_card_set_value (_tmp4_, ((double) NAN));
}

static void
ft_stats_week_page_update_category_colors (FtStatsWeekPage* self)
{
	GdkRGBA foreground_color = {0};
	FtBarChart* _tmp0_;
	GdkRGBA _tmp1_ = {0};
	GdkRGBA pomodoro_color = {0};
	GdkRGBA _tmp2_;
	GdkRGBA _tmp3_ = {0};
	GdkRGBA break_color = {0};
	GdkRGBA _tmp4_;
	GdkRGBA _tmp5_ = {0};
	FtBarChart* _tmp6_;
	GdkRGBA _tmp7_;
	FtBarChart* _tmp8_;
	GdkRGBA _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->histogram;
	gtk_widget_get_color ((GtkWidget*) _tmp0_, &_tmp1_);
	foreground_color = _tmp1_;
	_tmp2_ = foreground_color;
	ft_get_chart_primary_color (&_tmp2_, &_tmp3_);
	pomodoro_color = _tmp3_;
	_tmp4_ = foreground_color;
	ft_get_chart_secondary_color (&_tmp4_, &_tmp5_);
	break_color = _tmp5_;
	_tmp6_ = self->priv->histogram;
	_tmp7_ = pomodoro_color;
	ft_bar_chart_set_category_color (_tmp6_, (guint) FT_STATS_CATEGORY_POMODORO, &_tmp7_);
	_tmp8_ = self->priv->histogram;
	_tmp9_ = break_color;
	ft_bar_chart_set_category_color (_tmp8_, (guint) FT_STATS_CATEGORY_BREAK, &_tmp9_);
}

static void
ft_stats_week_page_update_histogram_labels (FtStatsWeekPage* self)
{
	GDate* date = NULL;
	GDate* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_date_copy (&self->priv->start_date);
	date = _tmp0_;
	{
		gint bar_index = 0;
		bar_index = 0;
		{
			gboolean _tmp1_ = FALSE;
			_tmp1_ = TRUE;
			while (TRUE) {
				gchar* bar_label = NULL;
				GDate* _tmp3_;
				GDate _tmp4_;
				gchar* _tmp5_;
				gchar* _tmp6_;
				gchar* _tmp7_;
				gchar* _tmp8_;
				gchar* tooltip_label = NULL;
				GDate* _tmp9_;
				GDate _tmp10_;
				gchar* _tmp11_;
				gchar* _tmp12_;
				gchar* _tmp13_;
				gchar* _tmp14_;
				FtBarChart* _tmp15_;
				const gchar* _tmp16_;
				const gchar* _tmp17_;
				GDate* _tmp18_;
				if (!_tmp1_) {
					gint _tmp2_;
					_tmp2_ = bar_index;
					bar_index = _tmp2_ + 1;
				}
				_tmp1_ = FALSE;
				if (!(bar_index <= 6)) {
					break;
				}
				_tmp3_ = date;
				_tmp4_ = *_tmp3_;
				_tmp5_ = ft_date_utils_format_date (&_tmp4_, "%a");
				_tmp6_ = _tmp5_;
				_tmp7_ = ft_capitalize_words (_tmp6_);
				_tmp8_ = _tmp7_;
				_g_free0 (_tmp6_);
				bar_label = _tmp8_;
				_tmp9_ = date;
				_tmp10_ = *_tmp9_;
				_tmp11_ = ft_date_utils_format_date (&_tmp10_, "%e %B");
				_tmp12_ = _tmp11_;
				_tmp13_ = ft_capitalize_words (_tmp12_);
				_tmp14_ = _tmp13_;
				_g_free0 (_tmp12_);
				tooltip_label = _tmp14_;
				_tmp15_ = self->priv->histogram;
				_tmp16_ = bar_label;
				_tmp17_ = tooltip_label;
				ft_bar_chart_set_bar_label (_tmp15_, (guint) bar_index, _tmp16_, _tmp17_);
				_tmp18_ = date;
				g_date_add_days (_tmp18_, 1U);
				_g_free0 (tooltip_label);
				_g_free0 (bar_label);
			}
		}
	}
	_g_free0 (date);
}

static void
ft_stats_week_page_fetch_aggregated_entries_data_free (gpointer _data)
{
	FtStatsWeekPageFetchAggregatedEntriesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtStatsWeekPageFetchAggregatedEntriesData, _data_);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
ft_stats_week_page_fetch_aggregated_entries (FtStatsWeekPage* self,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	FtStatsWeekPageFetchAggregatedEntriesData* _data_;
	FtStatsWeekPage* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (FtStatsWeekPageFetchAggregatedEntriesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_stats_week_page_fetch_aggregated_entries_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	ft_stats_week_page_fetch_aggregated_entries_co (_data_);
}

static GomResourceGroup*
ft_stats_week_page_fetch_aggregated_entries_finish (FtStatsWeekPage* self,
                                                    GAsyncResult* _res_)
{
	GomResourceGroup* result;
	FtStatsWeekPageFetchAggregatedEntriesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
ft_stats_week_page_fetch_aggregated_entries_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_)
{
	FtStatsWeekPageFetchAggregatedEntriesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ft_stats_week_page_fetch_aggregated_entries_co (_data_);
}

static gboolean
ft_stats_week_page_fetch_aggregated_entries_co (FtStatsWeekPageFetchAggregatedEntriesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ft_database_get_repository ();
	_data_->_tmp1_ = _g_object_ref0 (_data_->_tmp0_);
	_data_->repository = _data_->_tmp1_;
	memset (&_data_->_tmp2_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp2_, G_TYPE_STRING);
	_data_->start_date_value = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->self->priv->start_date;
	_data_->_tmp4_ = ft_database_serialize_date (&_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	g_value_set_string (&_data_->start_date_value, _data_->_tmp5_);
	_g_free0 (_data_->_tmp5_);
	memset (&_data_->_tmp6_, 0, sizeof (GValue));
	g_value_init (&_data_->_tmp6_, G_TYPE_STRING);
	_data_->end_date_value = _data_->_tmp6_;
	_data_->_tmp7_ = _data_->self->priv->end_date;
	_data_->_tmp8_ = ft_database_serialize_date (&_data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	g_value_set_string (&_data_->end_date_value, _data_->_tmp9_);
	_g_free0 (_data_->_tmp9_);
	_data_->_tmp10_ = _data_->start_date_value;
	_data_->_tmp11_ = gom_filter_new_gte (FT_TYPE_AGGREGATED_STATS_ENTRY, "date", &_data_->_tmp10_);
	g_object_ref_sink (_data_->_tmp11_);
	_data_->start_date_filter = _data_->_tmp11_;
	_data_->_tmp12_ = _data_->end_date_value;
	_data_->_tmp13_ = gom_filter_new_lte (FT_TYPE_AGGREGATED_STATS_ENTRY, "date", &_data_->_tmp12_);
	g_object_ref_sink (_data_->_tmp13_);
	_data_->end_date_filter = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->start_date_filter;
	_data_->_tmp15_ = _data_->end_date_filter;
	_data_->_tmp16_ = gom_filter_new_and (_data_->_tmp14_, _data_->_tmp15_);
	g_object_ref_sink (_data_->_tmp16_);
	_data_->date_filter = _data_->_tmp16_;
	{
		_data_->_tmp17_ = _data_->repository;
		_data_->_tmp18_ = _data_->date_filter;
		_data_->_state_ = 1;
		gom_repository_find_async (_data_->_tmp17_, FT_TYPE_AGGREGATED_STATS_ENTRY, _data_->_tmp18_, ft_stats_week_page_fetch_aggregated_entries_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp19_ = gom_repository_find_finish (_data_->_tmp17_, _data_->_res_, &_data_->_inner_error0_);
		_data_->aggregated_entries = _data_->_tmp19_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp20_ = _data_->aggregated_entries;
		_data_->_tmp21_ = _data_->aggregated_entries;
		_data_->_tmp22_ = gom_resource_group_get_count (_data_->_tmp21_);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_state_ = 2;
		gom_resource_group_fetch_async (_data_->_tmp20_, 0U, _data_->_tmp23_, ft_stats_week_page_fetch_aggregated_entries_ready, _data_);
		return FALSE;
		_state_2:
		gom_resource_group_fetch_finish (_data_->_tmp20_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->aggregated_entries);
			goto __catch0_g_error;
		}
		_data_->result = _data_->aggregated_entries;
		_g_object_unref0 (_data_->date_filter);
		_g_object_unref0 (_data_->end_date_filter);
		_g_object_unref0 (_data_->start_date_filter);
		G_IS_VALUE (&_data_->end_date_value) ? (g_value_unset (&_data_->end_date_value), NULL) : NULL;
		G_IS_VALUE (&_data_->start_date_value) ? (g_value_unset (&_data_->start_date_value), NULL) : NULL;
		_g_object_unref0 (_data_->repository);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp24_ = _data_->_error_;
		_data_->_tmp25_ = _data_->_tmp24_->message;
		g_critical ("stats-week-page.vala:153: Error while fetching weekly stats: %s", _data_->_tmp25_);
		_data_->result = NULL;
		_g_error_free0 (_data_->_error_);
		_g_object_unref0 (_data_->date_filter);
		_g_object_unref0 (_data_->end_date_filter);
		_g_object_unref0 (_data_->start_date_filter);
		G_IS_VALUE (&_data_->end_date_value) ? (g_value_unset (&_data_->end_date_value), NULL) : NULL;
		G_IS_VALUE (&_data_->start_date_value) ? (g_value_unset (&_data_->start_date_value), NULL) : NULL;
		_g_object_unref0 (_data_->repository);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	_g_object_unref0 (_data_->date_filter);
	_g_object_unref0 (_data_->end_date_filter);
	_g_object_unref0 (_data_->start_date_filter);
	G_IS_VALUE (&_data_->end_date_value) ? (g_value_unset (&_data_->end_date_value), NULL) : NULL;
	G_IS_VALUE (&_data_->start_date_value) ? (g_value_unset (&_data_->start_date_value), NULL) : NULL;
	_g_object_unref0 (_data_->repository);
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
	g_clear_error (&_data_->_inner_error0_);
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
ft_stats_week_page_process_aggregated_entry (FtStatsWeekPage* self,
                                             FtAggregatedStatsEntry* entry)
{
	gint entry_category = 0;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GDate entry_date = {0};
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GDate _tmp4_ = {0};
	gint64 entry_duration = 0LL;
	gint64 _tmp5_;
	gint64 _tmp6_;
	guint bar_index = 0U;
	GDate _tmp7_;
	gint category_index = 0;
	gdouble _tmp8_ = 0.0;
	gdouble bucket_value = 0.0;
	FtBarChart* _tmp11_;
	gdouble total = 0.0;
	FtStatsCard* _tmp24_;
	gdouble _tmp25_;
	gdouble _tmp26_;
	FtStatsCard* _tmp27_;
	gdouble _tmp28_;
	gdouble _tmp29_;
	gdouble _tmp30_ = 0.0;
	FtStatsCard* _tmp34_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (entry != NULL);
	_tmp0_ = ft_aggregated_stats_entry_get_category (entry);
	_tmp1_ = _tmp0_;
	entry_category = ft_stats_category_from_string (_tmp1_);
	_tmp2_ = ft_aggregated_stats_entry_get_date (entry);
	_tmp3_ = _tmp2_;
	ft_database_parse_date (_tmp3_, &_tmp4_);
	entry_date = _tmp4_;
	_tmp5_ = ft_aggregated_stats_entry_get_duration (entry);
	_tmp6_ = _tmp5_;
	entry_duration = _tmp6_;
	if (entry_category == ((gint) FT_STATS_CATEGORY_INVALID)) {
		return;
	}
	_tmp7_ = entry_date;
	bar_index = (guint) MAX (g_date_days_between (&self->priv->start_date, &_tmp7_), 0);
	category_index = (gint) entry_category;
	if (entry_category != ((gint) FT_STATS_CATEGORY_INTERRUPTION)) {
		_tmp8_ = ft_interval_to_seconds (entry_duration);
	} else {
		gint64 _tmp9_;
		gint64 _tmp10_;
		_tmp9_ = ft_aggregated_stats_entry_get_count (entry);
		_tmp10_ = _tmp9_;
		_tmp8_ = (gdouble) _tmp10_;
	}
	bucket_value = _tmp8_;
	_tmp11_ = self->priv->histogram;
	ft_bar_chart_add_value (_tmp11_, bar_index, (guint) category_index, bucket_value);
	switch (entry_category) {
		case FT_STATS_CATEGORY_POMODORO:
		{
			FtStatsCard* _tmp12_;
			FtStatsCard* _tmp13_;
			gdouble _tmp14_;
			gdouble _tmp15_;
			_tmp12_ = self->priv->pomodoro_card;
			_tmp13_ = self->priv->pomodoro_card;
			_tmp14_ = ft_stats_card_get_value (_tmp13_);
			_tmp15_ = _tmp14_;
			ft_stats_card_set_value (_tmp13_, _tmp15_ + bucket_value);
			break;
		}
		case FT_STATS_CATEGORY_BREAK:
		{
			FtStatsCard* _tmp16_;
			FtStatsCard* _tmp17_;
			gdouble _tmp18_;
			gdouble _tmp19_;
			_tmp16_ = self->priv->breaks_card;
			_tmp17_ = self->priv->breaks_card;
			_tmp18_ = ft_stats_card_get_value (_tmp17_);
			_tmp19_ = _tmp18_;
			ft_stats_card_set_value (_tmp17_, _tmp19_ + bucket_value);
			break;
		}
		case FT_STATS_CATEGORY_INTERRUPTION:
		{
			FtStatsCard* _tmp20_;
			FtStatsCard* _tmp21_;
			gdouble _tmp22_;
			gdouble _tmp23_;
			_tmp20_ = self->priv->interruptions_card;
			_tmp21_ = self->priv->interruptions_card;
			_tmp22_ = ft_stats_card_get_value (_tmp21_);
			_tmp23_ = _tmp22_;
			ft_stats_card_set_value (_tmp21_, _tmp23_ + bucket_value);
			break;
		}
		default:
		{
			break;
		}
	}
	_tmp24_ = self->priv->pomodoro_card;
	_tmp25_ = ft_stats_card_get_value (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = self->priv->breaks_card;
	_tmp28_ = ft_stats_card_get_value (_tmp27_);
	_tmp29_ = _tmp28_;
	total = _tmp26_ + _tmp29_;
	if (total >= 3600.0) {
		FtStatsCard* _tmp31_;
		gdouble _tmp32_;
		gdouble _tmp33_;
		_tmp31_ = self->priv->breaks_card;
		_tmp32_ = ft_stats_card_get_value (_tmp31_);
		_tmp33_ = _tmp32_;
		_tmp30_ = _tmp33_ / total;
	} else {
		_tmp30_ = ((double) NAN);
	}
	_tmp34_ = self->priv->break_ratio_card;
	ft_stats_card_set_value (_tmp34_, _tmp30_);
}

static void
ft_stats_week_page_process_entry (FtStatsWeekPage* self,
                                  FtStatsEntry* entry,
                                  gint sign)
{
	gint entry_category = 0;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GDate entry_date = {0};
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GDate _tmp4_ = {0};
	gint64 entry_duration = 0LL;
	gint64 _tmp5_;
	gint64 _tmp6_;
	gboolean _tmp7_ = FALSE;
	GDate _tmp8_;
	guint bar_index = 0U;
	GDate _tmp10_;
	gint category_index = 0;
	gdouble _tmp11_ = 0.0;
	gdouble bucket_value = 0.0;
	FtBarChart* _tmp12_;
	gdouble total = 0.0;
	FtStatsCard* _tmp25_;
	gdouble _tmp26_;
	gdouble _tmp27_;
	FtStatsCard* _tmp28_;
	gdouble _tmp29_;
	gdouble _tmp30_;
	gdouble _tmp31_ = 0.0;
	FtStatsCard* _tmp35_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (entry != NULL);
	_vala_return_if_fail ((sign == 1) || (sign == -1), "sign == 1 || sign == -1");
	_tmp0_ = ft_stats_entry_get_category (entry);
	_tmp1_ = _tmp0_;
	entry_category = ft_stats_category_from_string (_tmp1_);
	_tmp2_ = ft_stats_entry_get_date (entry);
	_tmp3_ = _tmp2_;
	ft_database_parse_date (_tmp3_, &_tmp4_);
	entry_date = _tmp4_;
	_tmp5_ = ft_stats_entry_get_duration (entry);
	_tmp6_ = _tmp5_;
	entry_duration = _tmp6_;
	if (entry_category == ((gint) FT_STATS_CATEGORY_INVALID)) {
		return;
	}
	_tmp8_ = self->priv->start_date;
	if (g_date_compare (&entry_date, &_tmp8_) < 0) {
		_tmp7_ = TRUE;
	} else {
		GDate _tmp9_;
		_tmp9_ = self->priv->end_date;
		_tmp7_ = g_date_compare (&entry_date, &_tmp9_) > 0;
	}
	if (_tmp7_) {
		return;
	}
	_tmp10_ = entry_date;
	bar_index = (guint) MAX (g_date_days_between (&self->priv->start_date, &_tmp10_), 0);
	category_index = (gint) entry_category;
	if (entry_category != ((gint) FT_STATS_CATEGORY_INTERRUPTION)) {
		_tmp11_ = ft_interval_to_seconds (sign * entry_duration);
	} else {
		_tmp11_ = (gdouble) sign;
	}
	bucket_value = _tmp11_;
	_tmp12_ = self->priv->histogram;
	ft_bar_chart_add_value (_tmp12_, bar_index, (guint) category_index, bucket_value);
	switch (entry_category) {
		case FT_STATS_CATEGORY_POMODORO:
		{
			FtStatsCard* _tmp13_;
			FtStatsCard* _tmp14_;
			gdouble _tmp15_;
			gdouble _tmp16_;
			_tmp13_ = self->priv->pomodoro_card;
			_tmp14_ = self->priv->pomodoro_card;
			_tmp15_ = ft_stats_card_get_value (_tmp14_);
			_tmp16_ = _tmp15_;
			ft_stats_card_set_value (_tmp14_, _tmp16_ + bucket_value);
			break;
		}
		case FT_STATS_CATEGORY_BREAK:
		{
			FtStatsCard* _tmp17_;
			FtStatsCard* _tmp18_;
			gdouble _tmp19_;
			gdouble _tmp20_;
			_tmp17_ = self->priv->breaks_card;
			_tmp18_ = self->priv->breaks_card;
			_tmp19_ = ft_stats_card_get_value (_tmp18_);
			_tmp20_ = _tmp19_;
			ft_stats_card_set_value (_tmp18_, _tmp20_ + bucket_value);
			break;
		}
		case FT_STATS_CATEGORY_INTERRUPTION:
		{
			FtStatsCard* _tmp21_;
			FtStatsCard* _tmp22_;
			gdouble _tmp23_;
			gdouble _tmp24_;
			_tmp21_ = self->priv->interruptions_card;
			_tmp22_ = self->priv->interruptions_card;
			_tmp23_ = ft_stats_card_get_value (_tmp22_);
			_tmp24_ = _tmp23_;
			ft_stats_card_set_value (_tmp22_, _tmp24_ + bucket_value);
			break;
		}
		default:
		{
			break;
		}
	}
	_tmp25_ = self->priv->pomodoro_card;
	_tmp26_ = ft_stats_card_get_value (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = self->priv->breaks_card;
	_tmp29_ = ft_stats_card_get_value (_tmp28_);
	_tmp30_ = _tmp29_;
	total = _tmp27_ + _tmp30_;
	if (total >= 3600.0) {
		FtStatsCard* _tmp32_;
		gdouble _tmp33_;
		gdouble _tmp34_;
		_tmp32_ = self->priv->breaks_card;
		_tmp33_ = ft_stats_card_get_value (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp31_ = _tmp34_ / total;
	} else {
		_tmp31_ = ((double) NAN);
	}
	_tmp35_ = self->priv->break_ratio_card;
	ft_stats_card_set_value (_tmp35_, _tmp31_);
}

static void
ft_stats_week_page_populate_data_free (gpointer _data)
{
	FtStatsWeekPagePopulateData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FtStatsWeekPagePopulateData, _data_);
}

static void
ft_stats_week_page_populate (FtStatsWeekPage* self,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_)
{
	FtStatsWeekPagePopulateData* _data_;
	FtStatsWeekPage* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (FtStatsWeekPagePopulateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_stats_week_page_populate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	ft_stats_week_page_populate_co (_data_);
}

static void
ft_stats_week_page_populate_finish (FtStatsWeekPage* self,
                                    GAsyncResult* _res_)
{
	FtStatsWeekPagePopulateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
ft_stats_week_page_populate_ready (GObject* source_object,
                                   GAsyncResult* _res_,
                                   gpointer _user_data_)
{
	FtStatsWeekPagePopulateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	ft_stats_week_page_populate_co (_data_);
}

static gboolean
ft_stats_week_page_populate_co (FtStatsWeekPagePopulateData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	ft_stats_week_page_fetch_aggregated_entries (_data_->self, ft_stats_week_page_populate_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = ft_stats_week_page_fetch_aggregated_entries_finish (_data_->self, _data_->_res_);
	_data_->aggregated_entries = _data_->_tmp0_;
	ft_stats_week_page_update_histogram_labels (_data_->self);
	ft_stats_week_page_reset (_data_->self);
	{
		_data_->index = 0U;
		{
			_data_->_tmp1_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp1_) {
					_data_->_tmp2_ = _data_->index;
					_data_->index = _data_->_tmp2_ + 1;
				}
				_data_->_tmp1_ = FALSE;
				_data_->_tmp3_ = _data_->aggregated_entries;
				_data_->_tmp4_ = gom_resource_group_get_count (_data_->_tmp3_);
				_data_->_tmp5_ = _data_->_tmp4_;
				if (!(_data_->index < _data_->_tmp5_)) {
					break;
				}
				_data_->_tmp6_ = _data_->aggregated_entries;
				_data_->_tmp7_ = gom_resource_group_get_index (_data_->_tmp6_, _data_->index);
				ft_stats_week_page_process_aggregated_entry (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, FT_TYPE_AGGREGATED_STATS_ENTRY, FtAggregatedStatsEntry));
			}
		}
	}
	_g_object_unref0 (_data_->aggregated_entries);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
ft_stats_week_page_on_entry_saved (FtStatsWeekPage* self,
                                   FtStatsEntry* entry)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (entry != NULL);
	ft_stats_week_page_process_entry (self, entry, 1);
}

static void
ft_stats_week_page_on_entry_deleted (FtStatsWeekPage* self,
                                     FtStatsEntry* entry)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (entry != NULL);
	ft_stats_week_page_process_entry (self, entry, -1);
}

static void
ft_stats_week_page_on_bar_activated (FtStatsWeekPage* self,
                                     guint bar_index)
{
	GDate date = {0};
	GDate _tmp0_ = {0};
	GDate _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	g_return_if_fail (self != NULL);
	ft_stats_week_page_transform_position (self, bar_index, &_tmp0_);
	date = _tmp0_;
	_tmp1_ = date;
	_tmp2_ = ft_date_utils_date_to_variant (&_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_widget_activate_action_variant ((GtkWidget*) self, "stats.select-day", _tmp3_);
	_g_variant_unref0 (_tmp3_);
}

static void
_ft_stats_week_page_on_bar_activated_ft_bar_chart_bar_activated (FtBarChart* _sender,
                                                                 guint bar_index,
                                                                 gpointer self)
{
	ft_stats_week_page_on_bar_activated ((FtStatsWeekPage*) self, bar_index);
}

static void
ft_stats_week_page_real_css_changed (GtkWidget* base,
                                     GtkCssStyleChange* change)
{
	FtStatsWeekPage * self;
	self = (FtStatsWeekPage*) base;
	g_return_if_fail (change != NULL);
	GTK_WIDGET_CLASS (ft_stats_week_page_parent_class)->css_changed ((GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_bin_get_type (), AdwBin), change);
	ft_stats_week_page_update_category_colors (self);
}

static void
_ft_stats_week_page_on_entry_saved_ft_stats_manager_entry_saved (FtStatsManager* _sender,
                                                                 FtStatsEntry* entry,
                                                                 gpointer self)
{
	ft_stats_week_page_on_entry_saved ((FtStatsWeekPage*) self, entry);
}

static void
_ft_stats_week_page_on_entry_deleted_ft_stats_manager_entry_deleted (FtStatsManager* _sender,
                                                                     FtStatsEntry* entry,
                                                                     gpointer self)
{
	ft_stats_week_page_on_entry_deleted ((FtStatsWeekPage*) self, entry);
}

static void
ft_stats_week_page_real_dispose (GObject* base)
{
	FtStatsWeekPage * self;
	FtBarChart* _tmp0_;
	FtStatsManager* _tmp1_;
	self = (FtStatsWeekPage*) base;
	_tmp0_ = self->priv->histogram;
	ft_chart_set_format_value_func ((FtChart*) _tmp0_, NULL, NULL, NULL);
	_tmp1_ = self->priv->stats_manager;
	if (_tmp1_ != NULL) {
		FtStatsManager* _tmp2_;
		guint _tmp3_;
		FtStatsManager* _tmp4_;
		guint _tmp5_;
		_tmp2_ = self->priv->stats_manager;
		g_signal_parse_name ("entry-saved", FT_TYPE_STATS_MANAGER, &_tmp3_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp3_, 0, NULL, (GCallback) _ft_stats_week_page_on_entry_saved_ft_stats_manager_entry_saved, self);
		_tmp4_ = self->priv->stats_manager;
		g_signal_parse_name ("entry-deleted", FT_TYPE_STATS_MANAGER, &_tmp5_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp5_, 0, NULL, (GCallback) _ft_stats_week_page_on_entry_deleted_ft_stats_manager_entry_deleted, self);
		_g_object_unref0 (self->priv->stats_manager);
		self->priv->stats_manager = NULL;
	}
	G_OBJECT_CLASS (ft_stats_week_page_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_bin_get_type (), AdwBin));
}

static void
ft_stats_week_page_real_get_date (FtStatsPage* base,
                                  GDate * result)
{
	FtStatsWeekPage* self;
	GDate _tmp0_;
	self = (FtStatsWeekPage*) base;
	_tmp0_ = self->priv->_date;
	*result = _tmp0_;
	return;
}

static gboolean
_g_date_equal (const GDate * s1,
               const GDate * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return FALSE;
}

static void
ft_stats_week_page_real_set_date (FtStatsPage* base,
                                  GDate * value)
{
	FtStatsWeekPage* self;
	GDate old_value;
	self = (FtStatsWeekPage*) base;
	ft_stats_week_page_real_get_date (base, &old_value);
	if (_g_date_equal (value, &old_value) != TRUE) {
		GDate _tmp0_;
		_tmp0_ = *value;
		self->priv->_date = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, ft_stats_week_page_properties[FT_STATS_WEEK_PAGE_DATE_PROPERTY]);
	}
}

static gchar*
_ft_stats_week_page_format_hours_ft_format_value_func (gdouble value,
                                                       gpointer self)
{
	gchar* result;
	result = ft_stats_week_page_format_hours (value);
	return result;
}

static void
_ft_stats_week_page___lambda30_ (FtStatsWeekPage* self,
                                 GObject* obj,
                                 GAsyncResult* res)
{
	g_return_if_fail (res != NULL);
	ft_stats_week_page_populate_finish (self, res);
}

static void
__ft_stats_week_page___lambda30__gasync_ready_callback (GObject* source_object,
                                                        GAsyncResult* res,
                                                        gpointer self)
{
	_ft_stats_week_page___lambda30_ ((FtStatsWeekPage*) self, source_object, res);
	g_object_unref (self);
}

static GObject *
ft_stats_week_page_constructor (GType type,
                                guint n_construct_properties,
                                GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	FtStatsWeekPage * self;
	FtStatsManager* _tmp0_;
	FtStatsManager* _tmp1_;
	FtStatsManager* _tmp2_;
	FtBarChart* _tmp3_;
	FtBarChart* _tmp4_;
	FtBarChart* _tmp5_;
	FtBarChart* _tmp6_;
	FtBarChart* _tmp7_;
	FtBarChart* _tmp8_;
	FtBarChart* _tmp9_;
	FtBarChart* _tmp10_;
	GDate _tmp11_ = {0};
	GDate _tmp12_;
	GDate _tmp13_ = {0};
	GDate* _tmp14_;
	GDate* _tmp15_;
	parent_class = G_OBJECT_CLASS (ft_stats_week_page_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_STATS_WEEK_PAGE, FtStatsWeekPage);
	_tmp0_ = ft_stats_manager_new ();
	_g_object_unref0 (self->priv->stats_manager);
	self->priv->stats_manager = _tmp0_;
	_tmp1_ = self->priv->stats_manager;
	g_signal_connect_object (_tmp1_, "entry-saved", (GCallback) _ft_stats_week_page_on_entry_saved_ft_stats_manager_entry_saved, self, 0);
	_tmp2_ = self->priv->stats_manager;
	g_signal_connect_object (_tmp2_, "entry-deleted", (GCallback) _ft_stats_week_page_on_entry_deleted_ft_stats_manager_entry_deleted, self, 0);
	_tmp3_ = self->priv->histogram;
	ft_chart_set_format_value_func ((FtChart*) _tmp3_, _ft_stats_week_page_format_hours_ft_format_value_func, NULL, NULL);
	_tmp4_ = self->priv->histogram;
	ft_bar_chart_set_category_label (_tmp4_, (guint) FT_STATS_CATEGORY_POMODORO, _ ("Pomodoro"));
	_tmp5_ = self->priv->histogram;
	ft_bar_chart_set_category_unit (_tmp5_, (guint) FT_STATS_CATEGORY_POMODORO, FT_UNIT_INTERVAL);
	_tmp6_ = self->priv->histogram;
	ft_bar_chart_set_category_label (_tmp6_, (guint) FT_STATS_CATEGORY_BREAK, _ ("Breaks"));
	_tmp7_ = self->priv->histogram;
	ft_bar_chart_set_category_unit (_tmp7_, (guint) FT_STATS_CATEGORY_BREAK, FT_UNIT_INTERVAL);
	_tmp8_ = self->priv->histogram;
	ft_bar_chart_set_category_label (_tmp8_, (guint) FT_STATS_CATEGORY_INTERRUPTION, _ ("Interruptions"));
	_tmp9_ = self->priv->histogram;
	ft_bar_chart_set_category_unit (_tmp9_, (guint) FT_STATS_CATEGORY_INTERRUPTION, FT_UNIT_AMOUNT);
	_tmp10_ = self->priv->histogram;
	ft_bar_chart_set_category_visible (_tmp10_, (guint) FT_STATS_CATEGORY_INTERRUPTION, FALSE);
	ft_stats_page_get_date ((FtStatsPage*) self, &_tmp11_);
	_tmp12_ = _tmp11_;
	ft_timeframe_normalize_date (FT_TIMEFRAME_WEEK, &_tmp12_, &_tmp13_);
	self->priv->start_date = _tmp13_;
	_tmp14_ = g_date_copy (&self->priv->start_date);
	_tmp15_ = _tmp14_;
	self->priv->end_date = *_tmp15_;
	_g_free0 (_tmp15_);
	g_date_add_days (&self->priv->end_date, 6U);
	ft_stats_week_page_populate (self, __ft_stats_week_page___lambda30__gasync_ready_callback, g_object_ref (self));
	return obj;
}

static void
ft_stats_week_page_class_init (FtStatsWeekPageClass * klass,
                               gpointer klass_data)
{
	ft_stats_week_page_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtStatsWeekPage_private_offset);
	((GtkWidgetClass *) klass)->css_changed = (void (*) (GtkWidget*, GtkCssStyleChange*)) ft_stats_week_page_real_css_changed;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_stats_week_page_real_dispose;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_stats_week_page_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_ft_stats_week_page_set_property;
	G_OBJECT_CLASS (klass)->constructor = ft_stats_week_page_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_stats_week_page_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_STATS_WEEK_PAGE_DATE_PROPERTY, ft_stats_week_page_properties[FT_STATS_WEEK_PAGE_DATE_PROPERTY] = g_param_spec_boxed ("date", "date", "date", G_TYPE_DATE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/io/github/focustimerhq/FocusTimer/ui/main/stats/stats-week-page.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "histogram", FALSE, FtStatsWeekPage_private_offset + G_STRUCT_OFFSET (FtStatsWeekPagePrivate, histogram));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "pomodoro_card", FALSE, FtStatsWeekPage_private_offset + G_STRUCT_OFFSET (FtStatsWeekPagePrivate, pomodoro_card));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "breaks_card", FALSE, FtStatsWeekPage_private_offset + G_STRUCT_OFFSET (FtStatsWeekPagePrivate, breaks_card));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "interruptions_card", FALSE, FtStatsWeekPage_private_offset + G_STRUCT_OFFSET (FtStatsWeekPagePrivate, interruptions_card));
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "break_ratio_card", FALSE, FtStatsWeekPage_private_offset + G_STRUCT_OFFSET (FtStatsWeekPagePrivate, break_ratio_card));
	gtk_widget_class_bind_template_callback_full (GTK_WIDGET_CLASS (klass), "on_bar_activated", G_CALLBACK(_ft_stats_week_page_on_bar_activated_ft_bar_chart_bar_activated));
}

static void
ft_stats_week_page_ft_stats_page_interface_init (FtStatsPageIface * iface,
                                                 gpointer iface_data)
{
	ft_stats_week_page_ft_stats_page_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_date = ft_stats_week_page_real_get_date;
	iface->set_date = ft_stats_week_page_real_set_date;
}

static void
ft_stats_week_page_instance_init (FtStatsWeekPage * self,
                                  gpointer klass)
{
	self->priv = ft_stats_week_page_get_instance_private (self);
	g_type_ensure (FT_TYPE_BAR_CHART);
	g_type_ensure (FT_TYPE_STATS_CARD);
	g_type_ensure (FT_TYPE_STATS_CARD);
	g_type_ensure (FT_TYPE_STATS_CARD);
	g_type_ensure (FT_TYPE_STATS_CARD);
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
ft_stats_week_page_finalize (GObject * obj)
{
	FtStatsWeekPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_STATS_WEEK_PAGE, FtStatsWeekPage);
	_g_object_unref0 (self->priv->stats_manager);
	G_OBJECT_CLASS (ft_stats_week_page_parent_class)->finalize (obj);
}

static GType
ft_stats_week_page_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtStatsWeekPageClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_stats_week_page_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtStatsWeekPage), 0, (GInstanceInitFunc) ft_stats_week_page_instance_init, NULL };
	static const GInterfaceInfo ft_stats_page_info = { (GInterfaceInitFunc) ft_stats_week_page_ft_stats_page_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType ft_stats_week_page_type_id;
	ft_stats_week_page_type_id = g_type_register_static (adw_bin_get_type (), "FtStatsWeekPage", &g_define_type_info, 0);
	g_type_add_interface_static (ft_stats_week_page_type_id, FT_TYPE_STATS_PAGE, &ft_stats_page_info);
	FtStatsWeekPage_private_offset = g_type_add_instance_private (ft_stats_week_page_type_id, sizeof (FtStatsWeekPagePrivate));
	return ft_stats_week_page_type_id;
}

GType
ft_stats_week_page_get_type (void)
{
	static volatile gsize ft_stats_week_page_type_id__once = 0;
	if (g_once_init_enter (&ft_stats_week_page_type_id__once)) {
		GType ft_stats_week_page_type_id;
		ft_stats_week_page_type_id = ft_stats_week_page_get_type_once ();
		g_once_init_leave (&ft_stats_week_page_type_id__once, ft_stats_week_page_type_id);
	}
	return ft_stats_week_page_type_id__once;
}

static void
_vala_ft_stats_week_page_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	FtStatsWeekPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_STATS_WEEK_PAGE, FtStatsWeekPage);
	switch (property_id) {
		case FT_STATS_WEEK_PAGE_DATE_PROPERTY:
		{
			GDate boxed;
			ft_stats_page_get_date ((FtStatsPage*) self, &boxed);
			g_value_set_boxed (value, &boxed);
		}
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_ft_stats_week_page_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	FtStatsWeekPage * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_STATS_WEEK_PAGE, FtStatsWeekPage);
	switch (property_id) {
		case FT_STATS_WEEK_PAGE_DATE_PROPERTY:
		ft_stats_page_set_date ((FtStatsPage*) self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

