/* Celebrate.c generated by valac 0.56.19, the Vala compiler
 * generated from Celebrate.vala, do not modify */

/* Celebrate is inspired by Warp's pride.rs*/
/* https://gitlab.gnome.org/World/warp/-/blob/main/src/ui/pride.rs*/

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <float.h>
#include <math.h>
#include <gobject/gvaluecollector.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define TUBA_UTILS_TYPE_CELEBRATE (tuba_utils_celebrate_get_type ())
#define TUBA_UTILS_CELEBRATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TUBA_UTILS_TYPE_CELEBRATE, TubaUtilsCelebrate))
#define TUBA_UTILS_CELEBRATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TUBA_UTILS_TYPE_CELEBRATE, TubaUtilsCelebrateClass))
#define TUBA_UTILS_IS_CELEBRATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TUBA_UTILS_TYPE_CELEBRATE))
#define TUBA_UTILS_IS_CELEBRATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TUBA_UTILS_TYPE_CELEBRATE))
#define TUBA_UTILS_CELEBRATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TUBA_UTILS_TYPE_CELEBRATE, TubaUtilsCelebrateClass))

typedef struct _TubaUtilsCelebrate TubaUtilsCelebrate;
typedef struct _TubaUtilsCelebrateClass TubaUtilsCelebrateClass;
typedef struct _TubaUtilsCelebratePrivate TubaUtilsCelebratePrivate;
typedef enum  {
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_INTERSEX,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_LESBIAN,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AIDS,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_PAN,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_TRANS,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BI,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AGENDER,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_DISABILITY,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BLACK_HISTORY,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ARO,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ACE,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_NON_BINARY,
	TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AUTISM
} TubaUtilsCelebrateCelebrateStyle;

#define TUBA_UTILS_CELEBRATE_TYPE_CELEBRATE_STYLE (tuba_utils_celebrate_celebrate_style_get_type ())

#define TUBA_UTILS_CELEBRATE_TYPE_CELEBRATION (tuba_utils_celebrate_celebration_get_type ())
typedef struct _TubaUtilsCelebrateCelebration TubaUtilsCelebrateCelebration;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _tuba_utils_celebrate_celebration_free0(var) ((var == NULL) ? NULL : (var = (tuba_utils_celebrate_celebration_free (var), NULL)))
typedef struct _TubaUtilsParamSpecCelebrate TubaUtilsParamSpecCelebrate;

struct _TubaUtilsCelebrate {
	GTypeInstance parent_instance;
	volatile int ref_count;
	TubaUtilsCelebratePrivate * priv;
};

struct _TubaUtilsCelebrateClass {
	GTypeClass parent_class;
	void (*finalize) (TubaUtilsCelebrate *self);
};

struct _TubaUtilsCelebrateCelebration {
	gint day;
	gint month;
	TubaUtilsCelebrateCelebrateStyle css_class;
};

struct _TubaUtilsParamSpecCelebrate {
	GParamSpec parent_instance;
};

static gpointer tuba_utils_celebrate_parent_class = NULL;

VALA_EXTERN gpointer tuba_utils_celebrate_ref (gpointer instance);
VALA_EXTERN void tuba_utils_celebrate_unref (gpointer instance);
VALA_EXTERN GParamSpec* tuba_utils_param_spec_celebrate (const gchar* name,
                                             const gchar* nick,
                                             const gchar* blurb,
                                             GType object_type,
                                             GParamFlags flags);
VALA_EXTERN void tuba_utils_value_set_celebrate (GValue* value,
                                     gpointer v_object);
VALA_EXTERN void tuba_utils_value_take_celebrate (GValue* value,
                                      gpointer v_object);
VALA_EXTERN gpointer tuba_utils_value_get_celebrate (const GValue* value);
VALA_EXTERN GType tuba_utils_celebrate_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (TubaUtilsCelebrate, tuba_utils_celebrate_unref)
static GType tuba_utils_celebrate_celebrate_style_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static gchar* tuba_utils_celebrate_celebrate_style_to_string (TubaUtilsCelebrateCelebrateStyle self);
static GType tuba_utils_celebrate_celebration_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static TubaUtilsCelebrateCelebration* tuba_utils_celebrate_celebration_dup (const TubaUtilsCelebrateCelebration* self);
static void tuba_utils_celebrate_celebration_free (TubaUtilsCelebrateCelebration* self);
static TubaUtilsCelebrateCelebration* tuba_utils_celebrate_get_dynamic_weeks (GDateTime* date,
                                                                       gint* result_length1);
static void tuba_utils_celebrate_get_arospec_week (GDateTime* date,
                                            TubaUtilsCelebrateCelebration* result);
static void tuba_utils_celebrate_get_ace_week (GDateTime* date,
                                        TubaUtilsCelebrateCelebration* result);
static void tuba_utils_celebrate_get_enby_week (GDateTime* date,
                                         TubaUtilsCelebrateCelebration* result);
VALA_EXTERN gchar* tuba_utils_celebrate_get_celebration_css_class (GDateTime* date);
static TubaUtilsCelebrateCelebration* tuba_utils_celebrate_get_celebration (GDateTime* date);
static TubaUtilsCelebrateCelebration* tuba_utils_celebrate_get_celebration_day (GDateTime* date);
static TubaUtilsCelebrateCelebration* tuba_utils_celebrate_get_celebration_week (GDateTime* date);
static TubaUtilsCelebrateCelebration* tuba_utils_celebrate_get_celebration_month (GDateTime* date);
static void _vala_array_add54 (TubaUtilsCelebrateCelebration* * array,
                        gint* length,
                        gint* size,
                        const TubaUtilsCelebrateCelebration* value);
static TubaUtilsCelebrateCelebration* tuba_utils_celebrate_get_random_item (TubaUtilsCelebrateCelebration* res,
                                                                     gint res_length1);
static void _vala_array_add55 (TubaUtilsCelebrateCelebration* * array,
                        gint* length,
                        gint* size,
                        const TubaUtilsCelebrateCelebration* value);
static void _vala_array_add56 (TubaUtilsCelebrateCelebration* * array,
                        gint* length,
                        gint* size,
                        const TubaUtilsCelebrateCelebration* value);
static void _vala_array_add57 (TubaUtilsCelebrateCelebration* * array,
                        gint* length,
                        gint* size,
                        const TubaUtilsCelebrateCelebration* value);
VALA_EXTERN TubaUtilsCelebrate* tuba_utils_celebrate_new (void);
VALA_EXTERN TubaUtilsCelebrate* tuba_utils_celebrate_construct (GType object_type);
static void tuba_utils_celebrate_finalize (TubaUtilsCelebrate * obj);
static GType tuba_utils_celebrate_get_type_once (void);

static const TubaUtilsCelebrateCelebration TUBA_UTILS_CELEBRATE_CELEBRATIONS_DAYS[10] = {{26, 10, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_INTERSEX}, {8, 11, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_INTERSEX}, {8, 10, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_LESBIAN}, {1, 12, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AIDS}, {18, 6, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AUTISM}, {24, 5, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_PAN}, {20, 11, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_TRANS}, {31, 3, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_TRANS}, {23, 9, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BI}, {19, 5, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AGENDER}};
static const TubaUtilsCelebrateCelebration TUBA_UTILS_CELEBRATE_CELEBRATIONS_WEEKS[3] = {{26, 4, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_LESBIAN}, {13, 11, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_TRANS}, {16, 9, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BI}};
static const TubaUtilsCelebrateCelebration TUBA_UTILS_CELEBRATE_CELEBRATIONS_MONTHS[3] = {{0, 7, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_DISABILITY}, {0, 2, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BLACK_HISTORY}, {0, 10, TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BLACK_HISTORY}};

static gchar*
tuba_utils_celebrate_celebrate_style_to_string (TubaUtilsCelebrateCelebrateStyle self)
{
	gchar* result;
	switch (self) {
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_INTERSEX:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("intersex");
			result = _tmp0_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_LESBIAN:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("lesbian");
			result = _tmp1_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AIDS:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("aids");
			result = _tmp2_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_PAN:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("pan");
			result = _tmp3_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_TRANS:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup ("trans");
			result = _tmp4_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BI:
		{
			gchar* _tmp5_;
			_tmp5_ = g_strdup ("bi");
			result = _tmp5_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AGENDER:
		{
			gchar* _tmp6_;
			_tmp6_ = g_strdup ("agender");
			result = _tmp6_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_DISABILITY:
		{
			gchar* _tmp7_;
			_tmp7_ = g_strdup ("disability");
			result = _tmp7_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BLACK_HISTORY:
		{
			gchar* _tmp8_;
			_tmp8_ = g_strdup ("black-history");
			result = _tmp8_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ARO:
		{
			gchar* _tmp9_;
			_tmp9_ = g_strdup ("aro");
			result = _tmp9_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ACE:
		{
			gchar* _tmp10_;
			_tmp10_ = g_strdup ("ace");
			result = _tmp10_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_NON_BINARY:
		{
			gchar* _tmp11_;
			_tmp11_ = g_strdup ("non-binary");
			result = _tmp11_;
			return result;
		}
		case TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AUTISM:
		{
			gchar* _tmp12_;
			_tmp12_ = g_strdup ("autism");
			result = _tmp12_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

 G_GNUC_NO_INLINE static GType
tuba_utils_celebrate_celebrate_style_get_type_once (void)
{
	static const GEnumValue values[] = {{TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_INTERSEX, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_INTERSEX", "intersex"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_LESBIAN, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_LESBIAN", "lesbian"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AIDS, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AIDS", "aids"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_PAN, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_PAN", "pan"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_TRANS, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_TRANS", "trans"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BI, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BI", "bi"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AGENDER, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AGENDER", "agender"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_DISABILITY, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_DISABILITY", "disability"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BLACK_HISTORY, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_BLACK_HISTORY", "black-history"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ARO, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ARO", "aro"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ACE, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ACE", "ace"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_NON_BINARY, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_NON_BINARY", "non-binary"}, {TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AUTISM, "TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_AUTISM", "autism"}, {0, NULL, NULL}};
	GType tuba_utils_celebrate_celebrate_style_type_id;
	tuba_utils_celebrate_celebrate_style_type_id = g_enum_register_static ("TubaUtilsCelebrateCelebrateStyle", values);
	return tuba_utils_celebrate_celebrate_style_type_id;
}

static GType
tuba_utils_celebrate_celebrate_style_get_type (void)
{
	static GType tuba_utils_celebrate_celebrate_style_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_utils_celebrate_celebrate_style_type_id__once)) {
		GType tuba_utils_celebrate_celebrate_style_type_id;
		tuba_utils_celebrate_celebrate_style_type_id = tuba_utils_celebrate_celebrate_style_get_type_once ();
		g_once_init_leave_pointer (&tuba_utils_celebrate_celebrate_style_type_id__once, tuba_utils_celebrate_celebrate_style_type_id);
	}
	return tuba_utils_celebrate_celebrate_style_type_id__once;
}

static TubaUtilsCelebrateCelebration*
tuba_utils_celebrate_get_dynamic_weeks (GDateTime* date,
                                        gint* result_length1)
{
	TubaUtilsCelebrateCelebration _tmp0_ = {0};
	TubaUtilsCelebrateCelebration _tmp1_ = {0};
	TubaUtilsCelebrateCelebration _tmp2_ = {0};
	TubaUtilsCelebrateCelebration* _tmp3_;
	TubaUtilsCelebrateCelebration* _tmp4_;
	gint _tmp4__length1;
	TubaUtilsCelebrateCelebration* result;
	g_return_val_if_fail (date != NULL, NULL);
	tuba_utils_celebrate_get_arospec_week (date, &_tmp0_);
	tuba_utils_celebrate_get_ace_week (date, &_tmp1_);
	tuba_utils_celebrate_get_enby_week (date, &_tmp2_);
	_tmp3_ = g_new0 (TubaUtilsCelebrateCelebration, 3);
	_tmp3_[0] = _tmp0_;
	_tmp3_[1] = _tmp1_;
	_tmp3_[2] = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp4__length1 = 3;
	if (result_length1) {
		*result_length1 = _tmp4__length1;
	}
	result = _tmp4_;
	return result;
}

static void
tuba_utils_celebrate_get_arospec_week (GDateTime* date,
                                       TubaUtilsCelebrateCelebration* result)
{
	GDateTime* february_14 = NULL;
	GDateTime* _tmp0_;
	gint weekday_offset = 0;
	gint start = 0;
	TubaUtilsCelebrateCelebration _tmp1_ = {0};
	g_return_if_fail (date != NULL);
	_tmp0_ = g_date_time_new_local (g_date_time_get_year (date), 2, 14, 0, 0, (gdouble) 0);
	february_14 = _tmp0_;
	weekday_offset = g_date_time_get_day_of_week (february_14) % 7;
	start = (14 + 7) - weekday_offset;
	_tmp1_.day = start;
	_tmp1_.month = 2;
	_tmp1_.css_class = TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ARO;
	*result = _tmp1_;
	_g_date_time_unref0 (february_14);
	return;
}

static void
tuba_utils_celebrate_get_ace_week (GDateTime* date,
                                   TubaUtilsCelebrateCelebration* result)
{
	GDateTime* last_day_october = NULL;
	GDateTime* _tmp0_;
	gint weekday_offset_last_day_october = 0;
	GDateTime* _tmp1_;
	gint _tmp2_ = 0;
	gint start = 0;
	TubaUtilsCelebrateCelebration _tmp3_ = {0};
	g_return_if_fail (date != NULL);
	_tmp0_ = g_date_time_new_local (g_date_time_get_year (date), 10, 31, 0, 0, (gdouble) 0);
	last_day_october = _tmp0_;
	_tmp1_ = last_day_october;
	weekday_offset_last_day_october = g_date_time_get_day_of_week (_tmp1_) % 7;
	if (weekday_offset_last_day_october == 6) {
		_tmp2_ = 31 - 7;
	} else {
		_tmp2_ = (31 - weekday_offset_last_day_october) - 7;
	}
	start = _tmp2_;
	_tmp3_.day = start;
	_tmp3_.month = 10;
	_tmp3_.css_class = TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_ACE;
	*result = _tmp3_;
	_g_date_time_unref0 (last_day_october);
	return;
}

static void
tuba_utils_celebrate_get_enby_week (GDateTime* date,
                                    TubaUtilsCelebrateCelebration* result)
{
	GDateTime* july_14 = NULL;
	GDateTime* _tmp0_;
	gint weekday_july_14_offset = 0;
	gint start = 0;
	TubaUtilsCelebrateCelebration _tmp1_ = {0};
	g_return_if_fail (date != NULL);
	_tmp0_ = g_date_time_new_local (g_date_time_get_year (date), 7, 14, 0, 0, (gdouble) 0);
	july_14 = _tmp0_;
	weekday_july_14_offset = g_date_time_get_day_of_week (july_14) - 1;
	start = 14 - weekday_july_14_offset;
	_tmp1_.day = start;
	_tmp1_.month = 7;
	_tmp1_.css_class = TUBA_UTILS_CELEBRATE_CELEBRATE_STYLE_NON_BINARY;
	*result = _tmp1_;
	_g_date_time_unref0 (july_14);
	return;
}

gchar*
tuba_utils_celebrate_get_celebration_css_class (GDateTime* date)
{
	TubaUtilsCelebrateCelebration* celebration = NULL;
	TubaUtilsCelebrateCelebration* _tmp0_;
	gchar* _tmp1_ = NULL;
	TubaUtilsCelebrateCelebration* _tmp2_;
	gchar* _tmp8_;
	gchar* result;
	g_return_val_if_fail (date != NULL, NULL);
	_tmp0_ = tuba_utils_celebrate_get_celebration (date);
	celebration = _tmp0_;
	_tmp2_ = celebration;
	if (_tmp2_ == NULL) {
		gchar* _tmp3_;
		_tmp3_ = g_strdup ("");
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp3_;
	} else {
		TubaUtilsCelebrateCelebration* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		_tmp4_ = celebration;
		_tmp5_ = tuba_utils_celebrate_celebrate_style_to_string ((*_tmp4_).css_class);
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strconcat ("theme-", _tmp6_, NULL);
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp7_;
		_g_free0 (_tmp6_);
	}
	_tmp8_ = _tmp1_;
	_tmp1_ = NULL;
	result = _tmp8_;
	_g_free0 (_tmp1_);
	_tuba_utils_celebrate_celebration_free0 (celebration);
	return result;
}

static TubaUtilsCelebrateCelebration*
tuba_utils_celebrate_get_celebration (GDateTime* date)
{
	TubaUtilsCelebrateCelebration* celebration = NULL;
	TubaUtilsCelebrateCelebration* _tmp0_;
	TubaUtilsCelebrateCelebration* _tmp1_;
	TubaUtilsCelebrateCelebration* _tmp3_;
	TubaUtilsCelebrateCelebration* result;
	g_return_val_if_fail (date != NULL, NULL);
	_tmp0_ = tuba_utils_celebrate_get_celebration_day (date);
	celebration = _tmp0_;
	_tmp1_ = celebration;
	if (_tmp1_ == NULL) {
		TubaUtilsCelebrateCelebration* _tmp2_;
		_tmp2_ = tuba_utils_celebrate_get_celebration_week (date);
		_tuba_utils_celebrate_celebration_free0 (celebration);
		celebration = _tmp2_;
	}
	_tmp3_ = celebration;
	if (_tmp3_ == NULL) {
		TubaUtilsCelebrateCelebration* _tmp4_;
		_tmp4_ = tuba_utils_celebrate_get_celebration_month (date);
		_tuba_utils_celebrate_celebration_free0 (celebration);
		celebration = _tmp4_;
	}
	result = celebration;
	return result;
}

static void
_vala_array_add54 (TubaUtilsCelebrateCelebration* * array,
                   gint* length,
                   gint* size,
                   const TubaUtilsCelebrateCelebration* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (TubaUtilsCelebrateCelebration, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static TubaUtilsCelebrateCelebration*
tuba_utils_celebrate_get_celebration_day (GDateTime* date)
{
	TubaUtilsCelebrateCelebration* res = NULL;
	TubaUtilsCelebrateCelebration* _tmp0_;
	gint res_length1;
	gint _res_size_;
	gint month = 0;
	gint day = 0;
	TubaUtilsCelebrateCelebration* _tmp5_;
	gint _tmp5__length1;
	TubaUtilsCelebrateCelebration* _tmp6_;
	TubaUtilsCelebrateCelebration* result;
	g_return_val_if_fail (date != NULL, NULL);
	_tmp0_ = g_new0 (TubaUtilsCelebrateCelebration, 0);
	res = _tmp0_;
	res_length1 = 0;
	_res_size_ = res_length1;
	month = g_date_time_get_month (date);
	day = g_date_time_get_day_of_month (date);
	{
		TubaUtilsCelebrateCelebration* celebration_collection = NULL;
		gint celebration_collection_length1 = 0;
		gint _celebration_collection_size_ = 0;
		gint celebration_it = 0;
		celebration_collection = TUBA_UTILS_CELEBRATE_CELEBRATIONS_DAYS;
		celebration_collection_length1 = G_N_ELEMENTS (TUBA_UTILS_CELEBRATE_CELEBRATIONS_DAYS);
		for (celebration_it = 0; celebration_it < celebration_collection_length1; celebration_it = celebration_it + 1) {
			TubaUtilsCelebrateCelebration celebration = {0};
			celebration = celebration_collection[celebration_it];
			{
				gboolean _tmp1_ = FALSE;
				TubaUtilsCelebrateCelebration _tmp2_;
				_tmp2_ = celebration;
				if (_tmp2_.month == month) {
					TubaUtilsCelebrateCelebration _tmp3_;
					_tmp3_ = celebration;
					_tmp1_ = _tmp3_.day == day;
				} else {
					_tmp1_ = FALSE;
				}
				if (_tmp1_) {
					TubaUtilsCelebrateCelebration _tmp4_;
					_tmp4_ = celebration;
					_vala_array_add54 (&res, &res_length1, &_res_size_, &_tmp4_);
				}
			}
		}
	}
	_tmp5_ = res;
	_tmp5__length1 = res_length1;
	_tmp6_ = tuba_utils_celebrate_get_random_item (_tmp5_, (gint) _tmp5__length1);
	result = _tmp6_;
	res = (g_free (res), NULL);
	return result;
}

static void
_vala_array_add55 (TubaUtilsCelebrateCelebration* * array,
                   gint* length,
                   gint* size,
                   const TubaUtilsCelebrateCelebration* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (TubaUtilsCelebrateCelebration, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static void
_vala_array_add56 (TubaUtilsCelebrateCelebration* * array,
                   gint* length,
                   gint* size,
                   const TubaUtilsCelebrateCelebration* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (TubaUtilsCelebrateCelebration, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static TubaUtilsCelebrateCelebration*
tuba_utils_celebrate_get_celebration_week (GDateTime* date)
{
	TubaUtilsCelebrateCelebration* res = NULL;
	TubaUtilsCelebrateCelebration* _tmp0_;
	gint res_length1;
	gint _res_size_;
	gint year = 0;
	gint day = 0;
	TubaUtilsCelebrateCelebration* weeks = NULL;
	gint _tmp1_ = 0;
	TubaUtilsCelebrateCelebration* _tmp2_;
	gint weeks_length1;
	gint _weeks_size_;
	TubaUtilsCelebrateCelebration* _tmp4_;
	gint _tmp4__length1;
	TubaUtilsCelebrateCelebration* _tmp14_;
	gint _tmp14__length1;
	TubaUtilsCelebrateCelebration* _tmp15_;
	TubaUtilsCelebrateCelebration* result;
	g_return_val_if_fail (date != NULL, NULL);
	_tmp0_ = g_new0 (TubaUtilsCelebrateCelebration, 0);
	res = _tmp0_;
	res_length1 = 0;
	_res_size_ = res_length1;
	year = g_date_time_get_year (date);
	day = g_date_time_get_day_of_year (date);
	_tmp2_ = tuba_utils_celebrate_get_dynamic_weeks (date, &_tmp1_);
	weeks = _tmp2_;
	weeks_length1 = _tmp1_;
	_weeks_size_ = weeks_length1;
	{
		TubaUtilsCelebrateCelebration* celebration_collection = NULL;
		gint celebration_collection_length1 = 0;
		gint _celebration_collection_size_ = 0;
		gint celebration_it = 0;
		celebration_collection = TUBA_UTILS_CELEBRATE_CELEBRATIONS_WEEKS;
		celebration_collection_length1 = G_N_ELEMENTS (TUBA_UTILS_CELEBRATE_CELEBRATIONS_WEEKS);
		for (celebration_it = 0; celebration_it < celebration_collection_length1; celebration_it = celebration_it + 1) {
			TubaUtilsCelebrateCelebration celebration = {0};
			celebration = celebration_collection[celebration_it];
			{
				TubaUtilsCelebrateCelebration _tmp3_;
				_tmp3_ = celebration;
				_vala_array_add55 (&weeks, &weeks_length1, &_weeks_size_, &_tmp3_);
			}
		}
	}
	_tmp4_ = weeks;
	_tmp4__length1 = weeks_length1;
	{
		TubaUtilsCelebrateCelebration* celebration_collection = NULL;
		gint celebration_collection_length1 = 0;
		gint _celebration_collection_size_ = 0;
		gint celebration_it = 0;
		celebration_collection = _tmp4_;
		celebration_collection_length1 = _tmp4__length1;
		for (celebration_it = 0; celebration_it < celebration_collection_length1; celebration_it = celebration_it + 1) {
			TubaUtilsCelebrateCelebration celebration = {0};
			celebration = celebration_collection[celebration_it];
			{
				GDateTime* celebration_pre_week = NULL;
				TubaUtilsCelebrateCelebration _tmp5_;
				TubaUtilsCelebrateCelebration _tmp6_;
				GDateTime* _tmp7_;
				GDateTime* week = NULL;
				GDateTime* _tmp8_;
				GDateTime* _tmp9_;
				gboolean _tmp10_ = FALSE;
				GDateTime* _tmp11_;
				_tmp5_ = celebration;
				_tmp6_ = celebration;
				_tmp7_ = g_date_time_new_local (year, _tmp5_.month, _tmp6_.day, 0, 0, (gdouble) 0);
				celebration_pre_week = _tmp7_;
				_tmp8_ = celebration_pre_week;
				_tmp9_ = g_date_time_add_weeks (_tmp8_, 1);
				week = _tmp9_;
				_tmp11_ = celebration_pre_week;
				if (day >= g_date_time_get_day_of_year (_tmp11_)) {
					GDateTime* _tmp12_;
					_tmp12_ = week;
					_tmp10_ = day <= (g_date_time_get_day_of_year (_tmp12_) - 1);
				} else {
					_tmp10_ = FALSE;
				}
				if (_tmp10_) {
					TubaUtilsCelebrateCelebration _tmp13_;
					_tmp13_ = celebration;
					_vala_array_add56 (&res, &res_length1, &_res_size_, &_tmp13_);
				}
				_g_date_time_unref0 (week);
				_g_date_time_unref0 (celebration_pre_week);
			}
		}
	}
	_tmp14_ = res;
	_tmp14__length1 = res_length1;
	_tmp15_ = tuba_utils_celebrate_get_random_item (_tmp14_, (gint) _tmp14__length1);
	result = _tmp15_;
	weeks = (g_free (weeks), NULL);
	res = (g_free (res), NULL);
	return result;
}

static void
_vala_array_add57 (TubaUtilsCelebrateCelebration* * array,
                   gint* length,
                   gint* size,
                   const TubaUtilsCelebrateCelebration* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (TubaUtilsCelebrateCelebration, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

static TubaUtilsCelebrateCelebration*
tuba_utils_celebrate_get_celebration_month (GDateTime* date)
{
	TubaUtilsCelebrateCelebration* res = NULL;
	TubaUtilsCelebrateCelebration* _tmp0_;
	gint res_length1;
	gint _res_size_;
	gint month = 0;
	TubaUtilsCelebrateCelebration* _tmp3_;
	gint _tmp3__length1;
	TubaUtilsCelebrateCelebration* _tmp4_;
	gint _tmp4__length1;
	TubaUtilsCelebrateCelebration* _tmp5_;
	TubaUtilsCelebrateCelebration* result;
	g_return_val_if_fail (date != NULL, NULL);
	_tmp0_ = g_new0 (TubaUtilsCelebrateCelebration, 0);
	res = _tmp0_;
	res_length1 = 0;
	_res_size_ = res_length1;
	month = g_date_time_get_month (date);
	{
		TubaUtilsCelebrateCelebration* celebration_collection = NULL;
		gint celebration_collection_length1 = 0;
		gint _celebration_collection_size_ = 0;
		gint celebration_it = 0;
		celebration_collection = TUBA_UTILS_CELEBRATE_CELEBRATIONS_MONTHS;
		celebration_collection_length1 = G_N_ELEMENTS (TUBA_UTILS_CELEBRATE_CELEBRATIONS_MONTHS);
		for (celebration_it = 0; celebration_it < celebration_collection_length1; celebration_it = celebration_it + 1) {
			TubaUtilsCelebrateCelebration celebration = {0};
			celebration = celebration_collection[celebration_it];
			{
				TubaUtilsCelebrateCelebration _tmp1_;
				_tmp1_ = celebration;
				if (_tmp1_.month == month) {
					TubaUtilsCelebrateCelebration _tmp2_;
					_tmp2_ = celebration;
					_vala_array_add57 (&res, &res_length1, &_res_size_, &_tmp2_);
				}
			}
		}
	}
	_tmp3_ = res;
	_tmp3__length1 = res_length1;
	if (_tmp3__length1 == 0) {
		result = NULL;
		res = (g_free (res), NULL);
		return result;
	}
	_tmp4_ = res;
	_tmp4__length1 = res_length1;
	_tmp5_ = tuba_utils_celebrate_get_random_item (_tmp4_, (gint) _tmp4__length1);
	result = _tmp5_;
	res = (g_free (res), NULL);
	return result;
}

static gpointer
_tuba_utils_celebrate_celebration_dup0 (gpointer self)
{
	return self ? tuba_utils_celebrate_celebration_dup (self) : NULL;
}

static TubaUtilsCelebrateCelebration*
tuba_utils_celebrate_get_random_item (TubaUtilsCelebrateCelebration* res,
                                      gint res_length1)
{
	TubaUtilsCelebrateCelebration _tmp2_;
	TubaUtilsCelebrateCelebration* _tmp3_;
	TubaUtilsCelebrateCelebration* result;
	if (res_length1 == 0) {
		result = NULL;
		return result;
	}
	if (res_length1 == 1) {
		TubaUtilsCelebrateCelebration _tmp0_;
		TubaUtilsCelebrateCelebration* _tmp1_;
		_tmp0_ = res[0];
		_tmp1_ = _tuba_utils_celebrate_celebration_dup0 (&_tmp0_);
		result = _tmp1_;
		return result;
	}
	_tmp2_ = res[g_random_int_range ((gint32) 0, (gint32) res_length1)];
	_tmp3_ = _tuba_utils_celebrate_celebration_dup0 (&_tmp2_);
	result = _tmp3_;
	return result;
}

TubaUtilsCelebrate*
tuba_utils_celebrate_construct (GType object_type)
{
	TubaUtilsCelebrate* self = NULL;
	self = (TubaUtilsCelebrate*) g_type_create_instance (object_type);
	return self;
}

TubaUtilsCelebrate*
tuba_utils_celebrate_new (void)
{
	return tuba_utils_celebrate_construct (TUBA_UTILS_TYPE_CELEBRATE);
}

static TubaUtilsCelebrateCelebration*
tuba_utils_celebrate_celebration_dup (const TubaUtilsCelebrateCelebration* self)
{
	TubaUtilsCelebrateCelebration* dup;
	dup = g_new0 (TubaUtilsCelebrateCelebration, 1);
	memcpy (dup, self, sizeof (TubaUtilsCelebrateCelebration));
	return dup;
}

static void
tuba_utils_celebrate_celebration_free (TubaUtilsCelebrateCelebration* self)
{
	g_free (self);
}

 G_GNUC_NO_INLINE static GType
tuba_utils_celebrate_celebration_get_type_once (void)
{
	GType tuba_utils_celebrate_celebration_type_id;
	tuba_utils_celebrate_celebration_type_id = g_boxed_type_register_static ("TubaUtilsCelebrateCelebration", (GBoxedCopyFunc) tuba_utils_celebrate_celebration_dup, (GBoxedFreeFunc) tuba_utils_celebrate_celebration_free);
	return tuba_utils_celebrate_celebration_type_id;
}

static GType
tuba_utils_celebrate_celebration_get_type (void)
{
	static GType tuba_utils_celebrate_celebration_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_utils_celebrate_celebration_type_id__once)) {
		GType tuba_utils_celebrate_celebration_type_id;
		tuba_utils_celebrate_celebration_type_id = tuba_utils_celebrate_celebration_get_type_once ();
		g_once_init_leave_pointer (&tuba_utils_celebrate_celebration_type_id__once, tuba_utils_celebrate_celebration_type_id);
	}
	return tuba_utils_celebrate_celebration_type_id__once;
}

static void
tuba_utils_value_celebrate_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
tuba_utils_value_celebrate_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		tuba_utils_celebrate_unref (value->data[0].v_pointer);
	}
}

static void
tuba_utils_value_celebrate_copy_value (const GValue* src_value,
                                       GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = tuba_utils_celebrate_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
tuba_utils_value_celebrate_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
tuba_utils_value_celebrate_collect_value (GValue* value,
                                          guint n_collect_values,
                                          GTypeCValue* collect_values,
                                          guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		TubaUtilsCelebrate * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = tuba_utils_celebrate_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
tuba_utils_value_celebrate_lcopy_value (const GValue* value,
                                        guint n_collect_values,
                                        GTypeCValue* collect_values,
                                        guint collect_flags)
{
	TubaUtilsCelebrate ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = tuba_utils_celebrate_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
tuba_utils_param_spec_celebrate (const gchar* name,
                                 const gchar* nick,
                                 const gchar* blurb,
                                 GType object_type,
                                 GParamFlags flags)
{
	TubaUtilsParamSpecCelebrate* spec;
	g_return_val_if_fail (g_type_is_a (object_type, TUBA_UTILS_TYPE_CELEBRATE), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
tuba_utils_value_get_celebrate (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_CELEBRATE), NULL);
	return value->data[0].v_pointer;
}

void
tuba_utils_value_set_celebrate (GValue* value,
                                gpointer v_object)
{
	TubaUtilsCelebrate * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_CELEBRATE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TUBA_UTILS_TYPE_CELEBRATE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		tuba_utils_celebrate_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tuba_utils_celebrate_unref (old);
	}
}

void
tuba_utils_value_take_celebrate (GValue* value,
                                 gpointer v_object)
{
	TubaUtilsCelebrate * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TUBA_UTILS_TYPE_CELEBRATE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TUBA_UTILS_TYPE_CELEBRATE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		tuba_utils_celebrate_unref (old);
	}
}

static void
tuba_utils_celebrate_class_init (TubaUtilsCelebrateClass * klass,
                                 gpointer klass_data)
{
	tuba_utils_celebrate_parent_class = g_type_class_peek_parent (klass);
	((TubaUtilsCelebrateClass *) klass)->finalize = tuba_utils_celebrate_finalize;
}

static void
tuba_utils_celebrate_instance_init (TubaUtilsCelebrate * self,
                                    gpointer klass)
{
	self->ref_count = 1;
}

static void
tuba_utils_celebrate_finalize (TubaUtilsCelebrate * obj)
{
	TubaUtilsCelebrate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TUBA_UTILS_TYPE_CELEBRATE, TubaUtilsCelebrate);
	g_signal_handlers_destroy (self);
}

 G_GNUC_NO_INLINE static GType
tuba_utils_celebrate_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { tuba_utils_value_celebrate_init, tuba_utils_value_celebrate_free_value, tuba_utils_value_celebrate_copy_value, tuba_utils_value_celebrate_peek_pointer, "p", tuba_utils_value_celebrate_collect_value, "p", tuba_utils_value_celebrate_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (TubaUtilsCelebrateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) tuba_utils_celebrate_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (TubaUtilsCelebrate), 0, (GInstanceInitFunc) tuba_utils_celebrate_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType tuba_utils_celebrate_type_id;
	tuba_utils_celebrate_type_id = g_type_register_fundamental (g_type_fundamental_next (), "TubaUtilsCelebrate", &g_define_type_info, &g_define_type_fundamental_info, G_TYPE_FLAG_NONE);
	return tuba_utils_celebrate_type_id;
}

GType
tuba_utils_celebrate_get_type (void)
{
	static GType tuba_utils_celebrate_type_id__once = 0;
	if (g_once_init_enter_pointer (&tuba_utils_celebrate_type_id__once)) {
		GType tuba_utils_celebrate_type_id;
		tuba_utils_celebrate_type_id = tuba_utils_celebrate_get_type_once ();
		g_once_init_leave_pointer (&tuba_utils_celebrate_type_id__once, tuba_utils_celebrate_type_id);
	}
	return tuba_utils_celebrate_type_id__once;
}

gpointer
tuba_utils_celebrate_ref (gpointer instance)
{
	TubaUtilsCelebrate * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
tuba_utils_celebrate_unref (gpointer instance)
{
	TubaUtilsCelebrate * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		TUBA_UTILS_CELEBRATE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

