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

#include "protonplus_core.h"
#include <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.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  {
	PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_0_PROPERTY,
	PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_VARIANT_PROPERTY,
	PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_MATCHING_VARIANT_PROPERTY,
	PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_HAS_EXPLICIT_SELECTION_PROPERTY,
	PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_NUM_PROPERTIES
};
static GParamSpec* proton_plus_models_installation_variant_resolution_properties[PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	PROTON_PLUS_MODELS_VARIANT_SELECTOR_0_PROPERTY,
	PROTON_PLUS_MODELS_VARIANT_SELECTOR_NUM_PROPERTIES
};
static GParamSpec* proton_plus_models_variant_selector_properties[PROTON_PLUS_MODELS_VARIANT_SELECTOR_NUM_PROPERTIES];

struct _ProtonPlusModelsInstallationVariantResolutionPrivate {
	ProtonPlusModelsVariant* _variant;
	ProtonPlusModelsVariant* _matching_variant;
	gboolean _has_explicit_selection;
};

static gint ProtonPlusModelsInstallationVariantResolution_private_offset;
static gpointer proton_plus_models_installation_variant_resolution_parent_class = NULL;
static gpointer proton_plus_models_variant_selector_parent_class = NULL;

static void proton_plus_models_installation_variant_resolution_set_variant (ProtonPlusModelsInstallationVariantResolution* self,
                                                                     ProtonPlusModelsVariant* value);
static void proton_plus_models_installation_variant_resolution_set_matching_variant (ProtonPlusModelsInstallationVariantResolution* self,
                                                                              ProtonPlusModelsVariant* value);
static void proton_plus_models_installation_variant_resolution_set_has_explicit_selection (ProtonPlusModelsInstallationVariantResolution* self,
                                                                                    gboolean value);
static void proton_plus_models_installation_variant_resolution_finalize (GObject * obj);
static GType proton_plus_models_installation_variant_resolution_get_type_once (void);
static void _vala_proton_plus_models_installation_variant_resolution_get_property (GObject * object,
                                                                            guint property_id,
                                                                            GValue * value,
                                                                            GParamSpec * pspec);
static void _vala_proton_plus_models_installation_variant_resolution_set_property (GObject * object,
                                                                            guint property_id,
                                                                            const GValue * value,
                                                                            GParamSpec * pspec);
static ProtonPlusModelsVariant* proton_plus_models_variant_selector_find_native_aarch64_variant (GeeIterable* variants,
                                                                                          ProtonPlusModelsCpuCapabilities* capabilities,
                                                                                          gboolean require_download_url);
static ProtonPlusModelsVariant* proton_plus_models_variant_selector_find_matching_release_variant (ProtonPlusModelsRelease* release,
                                                                                            ProtonPlusModelsVariant* selected_variant);
static gboolean proton_plus_models_variant_selector_has_download_url (ProtonPlusModelsVariant* variant);
static ProtonPlusModelsVariant* proton_plus_models_variant_selector_find_release_variant_by_id (ProtonPlusModelsRelease* release,
                                                                                         const gchar* id);
static ProtonPlusModelsVariant* proton_plus_models_variant_selector_find_release_variant_by_name (ProtonPlusModelsRelease* release,
                                                                                           const gchar* name);
static GType proton_plus_models_variant_selector_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
proton_plus_models_installation_variant_resolution_get_instance_private (ProtonPlusModelsInstallationVariantResolution* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusModelsInstallationVariantResolution_private_offset);
}

ProtonPlusModelsInstallationVariantResolution*
proton_plus_models_installation_variant_resolution_construct (GType object_type,
                                                              ProtonPlusModelsVariant* variant,
                                                              ProtonPlusModelsVariant* matching_variant,
                                                              gboolean has_explicit_selection)
{
	ProtonPlusModelsInstallationVariantResolution * self = NULL;
	self = (ProtonPlusModelsInstallationVariantResolution*) g_object_new (object_type, NULL);
	proton_plus_models_installation_variant_resolution_set_variant (self, variant);
	proton_plus_models_installation_variant_resolution_set_matching_variant (self, matching_variant);
	proton_plus_models_installation_variant_resolution_set_has_explicit_selection (self, has_explicit_selection);
	return self;
}

ProtonPlusModelsInstallationVariantResolution*
proton_plus_models_installation_variant_resolution_new (ProtonPlusModelsVariant* variant,
                                                        ProtonPlusModelsVariant* matching_variant,
                                                        gboolean has_explicit_selection)
{
	return proton_plus_models_installation_variant_resolution_construct (PROTON_PLUS_MODELS_TYPE_INSTALLATION_VARIANT_RESOLUTION, variant, matching_variant, has_explicit_selection);
}

ProtonPlusModelsVariant*
proton_plus_models_installation_variant_resolution_get_variant (ProtonPlusModelsInstallationVariantResolution* self)
{
	ProtonPlusModelsVariant* result;
	ProtonPlusModelsVariant* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_variant;
	result = _tmp0_;
	return result;
}

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

static void
proton_plus_models_installation_variant_resolution_set_variant (ProtonPlusModelsInstallationVariantResolution* self,
                                                                ProtonPlusModelsVariant* value)
{
	ProtonPlusModelsVariant* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_installation_variant_resolution_get_variant (self);
	if (old_value != value) {
		ProtonPlusModelsVariant* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_variant);
		self->priv->_variant = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_installation_variant_resolution_properties[PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_VARIANT_PROPERTY]);
	}
}

ProtonPlusModelsVariant*
proton_plus_models_installation_variant_resolution_get_matching_variant (ProtonPlusModelsInstallationVariantResolution* self)
{
	ProtonPlusModelsVariant* result;
	ProtonPlusModelsVariant* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_matching_variant;
	result = _tmp0_;
	return result;
}

static void
proton_plus_models_installation_variant_resolution_set_matching_variant (ProtonPlusModelsInstallationVariantResolution* self,
                                                                         ProtonPlusModelsVariant* value)
{
	ProtonPlusModelsVariant* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_installation_variant_resolution_get_matching_variant (self);
	if (old_value != value) {
		ProtonPlusModelsVariant* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_matching_variant);
		self->priv->_matching_variant = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_installation_variant_resolution_properties[PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_MATCHING_VARIANT_PROPERTY]);
	}
}

gboolean
proton_plus_models_installation_variant_resolution_get_has_explicit_selection (ProtonPlusModelsInstallationVariantResolution* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_has_explicit_selection;
	return result;
}

static void
proton_plus_models_installation_variant_resolution_set_has_explicit_selection (ProtonPlusModelsInstallationVariantResolution* self,
                                                                               gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_models_installation_variant_resolution_get_has_explicit_selection (self);
	if (old_value != value) {
		self->priv->_has_explicit_selection = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_models_installation_variant_resolution_properties[PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_HAS_EXPLICIT_SELECTION_PROPERTY]);
	}
}

static void
proton_plus_models_installation_variant_resolution_class_init (ProtonPlusModelsInstallationVariantResolutionClass * klass,
                                                               gpointer klass_data)
{
	proton_plus_models_installation_variant_resolution_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusModelsInstallationVariantResolution_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_models_installation_variant_resolution_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_models_installation_variant_resolution_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_models_installation_variant_resolution_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_VARIANT_PROPERTY, proton_plus_models_installation_variant_resolution_properties[PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_VARIANT_PROPERTY] = g_param_spec_object ("variant", "variant", "variant", PROTON_PLUS_MODELS_TYPE_VARIANT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_MATCHING_VARIANT_PROPERTY, proton_plus_models_installation_variant_resolution_properties[PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_MATCHING_VARIANT_PROPERTY] = g_param_spec_object ("matching-variant", "matching-variant", "matching-variant", PROTON_PLUS_MODELS_TYPE_VARIANT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_HAS_EXPLICIT_SELECTION_PROPERTY, proton_plus_models_installation_variant_resolution_properties[PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_HAS_EXPLICIT_SELECTION_PROPERTY] = g_param_spec_boolean ("has-explicit-selection", "has-explicit-selection", "has-explicit-selection", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
proton_plus_models_installation_variant_resolution_instance_init (ProtonPlusModelsInstallationVariantResolution * self,
                                                                  gpointer klass)
{
	self->priv = proton_plus_models_installation_variant_resolution_get_instance_private (self);
	self->priv->_variant = NULL;
	self->priv->_matching_variant = NULL;
	self->priv->_has_explicit_selection = FALSE;
}

static void
proton_plus_models_installation_variant_resolution_finalize (GObject * obj)
{
	ProtonPlusModelsInstallationVariantResolution * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_MODELS_TYPE_INSTALLATION_VARIANT_RESOLUTION, ProtonPlusModelsInstallationVariantResolution);
	_g_object_unref0 (self->priv->_variant);
	_g_object_unref0 (self->priv->_matching_variant);
	G_OBJECT_CLASS (proton_plus_models_installation_variant_resolution_parent_class)->finalize (obj);
}

static GType
proton_plus_models_installation_variant_resolution_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusModelsInstallationVariantResolutionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_models_installation_variant_resolution_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusModelsInstallationVariantResolution), 0, (GInstanceInitFunc) proton_plus_models_installation_variant_resolution_instance_init, NULL };
	GType proton_plus_models_installation_variant_resolution_type_id;
	proton_plus_models_installation_variant_resolution_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusModelsInstallationVariantResolution", &g_define_type_info, 0);
	ProtonPlusModelsInstallationVariantResolution_private_offset = g_type_add_instance_private (proton_plus_models_installation_variant_resolution_type_id, sizeof (ProtonPlusModelsInstallationVariantResolutionPrivate));
	return proton_plus_models_installation_variant_resolution_type_id;
}

GType
proton_plus_models_installation_variant_resolution_get_type (void)
{
	static volatile gsize proton_plus_models_installation_variant_resolution_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_models_installation_variant_resolution_type_id__once)) {
		GType proton_plus_models_installation_variant_resolution_type_id;
		proton_plus_models_installation_variant_resolution_type_id = proton_plus_models_installation_variant_resolution_get_type_once ();
		g_once_init_leave (&proton_plus_models_installation_variant_resolution_type_id__once, proton_plus_models_installation_variant_resolution_type_id);
	}
	return proton_plus_models_installation_variant_resolution_type_id__once;
}

static void
_vala_proton_plus_models_installation_variant_resolution_get_property (GObject * object,
                                                                       guint property_id,
                                                                       GValue * value,
                                                                       GParamSpec * pspec)
{
	ProtonPlusModelsInstallationVariantResolution * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_MODELS_TYPE_INSTALLATION_VARIANT_RESOLUTION, ProtonPlusModelsInstallationVariantResolution);
	switch (property_id) {
		case PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_VARIANT_PROPERTY:
		g_value_set_object (value, proton_plus_models_installation_variant_resolution_get_variant (self));
		break;
		case PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_MATCHING_VARIANT_PROPERTY:
		g_value_set_object (value, proton_plus_models_installation_variant_resolution_get_matching_variant (self));
		break;
		case PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_HAS_EXPLICIT_SELECTION_PROPERTY:
		g_value_set_boolean (value, proton_plus_models_installation_variant_resolution_get_has_explicit_selection (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_models_installation_variant_resolution_set_property (GObject * object,
                                                                       guint property_id,
                                                                       const GValue * value,
                                                                       GParamSpec * pspec)
{
	ProtonPlusModelsInstallationVariantResolution * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_MODELS_TYPE_INSTALLATION_VARIANT_RESOLUTION, ProtonPlusModelsInstallationVariantResolution);
	switch (property_id) {
		case PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_VARIANT_PROPERTY:
		proton_plus_models_installation_variant_resolution_set_variant (self, g_value_get_object (value));
		break;
		case PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_MATCHING_VARIANT_PROPERTY:
		proton_plus_models_installation_variant_resolution_set_matching_variant (self, g_value_get_object (value));
		break;
		case PROTON_PLUS_MODELS_INSTALLATION_VARIANT_RESOLUTION_HAS_EXPLICIT_SELECTION_PROPERTY:
		proton_plus_models_installation_variant_resolution_set_has_explicit_selection (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

GeeLinkedList*
proton_plus_models_variant_selector_compatible_variants (GeeIterable* variants,
                                                         ProtonPlusModelsCpuCapabilities* capabilities)
{
	GeeLinkedList* compatible = NULL;
	GeeLinkedList* _tmp0_;
	GeeLinkedList* result;
	g_return_val_if_fail (variants != NULL, NULL);
	g_return_val_if_fail (capabilities != NULL, NULL);
	_tmp0_ = gee_linked_list_new (PROTON_PLUS_MODELS_TYPE_VARIANT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	compatible = _tmp0_;
	{
		GeeIterator* _variant_it = NULL;
		GeeIterator* _tmp1_;
		_tmp1_ = gee_iterable_iterator (variants);
		_variant_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			ProtonPlusModelsVariant* _tmp5_;
			_tmp2_ = _variant_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _variant_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			variant = (ProtonPlusModelsVariant*) _tmp4_;
			_tmp5_ = variant;
			if (proton_plus_models_variant_is_compatible_with (_tmp5_, capabilities)) {
				GeeLinkedList* _tmp6_;
				ProtonPlusModelsVariant* _tmp7_;
				_tmp6_ = compatible;
				_tmp7_ = variant;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp6_, _tmp7_);
			}
			_g_object_unref0 (variant);
		}
		_g_object_unref0 (_variant_it);
	}
	result = compatible;
	return result;
}

gboolean
proton_plus_models_variant_selector_has_compatible_variants (GeeIterable* variants,
                                                             ProtonPlusModelsCpuCapabilities* capabilities)
{
	gboolean result;
	g_return_val_if_fail (variants != NULL, FALSE);
	g_return_val_if_fail (capabilities != NULL, FALSE);
	{
		GeeIterator* _variant_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator (variants);
		_variant_it = _tmp0_;
		while (TRUE) {
			GeeIterator* _tmp1_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeIterator* _tmp2_;
			gpointer _tmp3_;
			ProtonPlusModelsVariant* _tmp4_;
			_tmp1_ = _variant_it;
			if (!gee_iterator_next (_tmp1_)) {
				break;
			}
			_tmp2_ = _variant_it;
			_tmp3_ = gee_iterator_get (_tmp2_);
			variant = (ProtonPlusModelsVariant*) _tmp3_;
			_tmp4_ = variant;
			if (proton_plus_models_variant_is_compatible_with (_tmp4_, capabilities)) {
				result = TRUE;
				_g_object_unref0 (variant);
				_g_object_unref0 (_variant_it);
				return result;
			}
			_g_object_unref0 (variant);
		}
		_g_object_unref0 (_variant_it);
	}
	result = FALSE;
	return result;
}

ProtonPlusModelsVariant*
proton_plus_models_variant_selector_select_variant (GeeIterable* variants,
                                                    ProtonPlusModelsCpuCapabilities* capabilities,
                                                    const gchar* saved_variant_name)
{
	GeeLinkedList* compatible = NULL;
	GeeLinkedList* _tmp0_;
	ProtonPlusModelsVariant* native_aarch64 = NULL;
	GeeLinkedList* _tmp12_;
	ProtonPlusModelsVariant* _tmp13_;
	ProtonPlusModelsVariant* _tmp14_;
	ProtonPlusModelsVariant* _tmp26_ = NULL;
	GeeLinkedList* _tmp27_;
	gint _tmp28_;
	gint _tmp29_;
	ProtonPlusModelsVariant* _tmp32_;
	ProtonPlusModelsVariant* result;
	g_return_val_if_fail (variants != NULL, NULL);
	g_return_val_if_fail (capabilities != NULL, NULL);
	g_return_val_if_fail (saved_variant_name != NULL, NULL);
	_tmp0_ = proton_plus_models_variant_selector_compatible_variants (variants, capabilities);
	compatible = _tmp0_;
	if (g_strcmp0 (saved_variant_name, "") != 0) {
		{
			GeeLinkedList* _variant_list = NULL;
			GeeLinkedList* _tmp1_;
			gint _variant_size = 0;
			GeeLinkedList* _tmp2_;
			gint _tmp3_;
			gint _tmp4_;
			gint _variant_index = 0;
			_tmp1_ = compatible;
			_variant_list = _tmp1_;
			_tmp2_ = _variant_list;
			_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
			_tmp4_ = _tmp3_;
			_variant_size = _tmp4_;
			_variant_index = -1;
			while (TRUE) {
				gint _tmp5_;
				gint _tmp6_;
				ProtonPlusModelsVariant* variant = NULL;
				GeeLinkedList* _tmp7_;
				gpointer _tmp8_;
				ProtonPlusModelsVariant* _tmp9_;
				const gchar* _tmp10_;
				const gchar* _tmp11_;
				_variant_index = _variant_index + 1;
				_tmp5_ = _variant_index;
				_tmp6_ = _variant_size;
				if (!(_tmp5_ < _tmp6_)) {
					break;
				}
				_tmp7_ = _variant_list;
				_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _variant_index);
				variant = (ProtonPlusModelsVariant*) _tmp8_;
				_tmp9_ = variant;
				_tmp10_ = proton_plus_models_variant_get_name (_tmp9_);
				_tmp11_ = _tmp10_;
				if (g_strcmp0 (_tmp11_, saved_variant_name) == 0) {
					result = variant;
					_g_object_unref0 (compatible);
					return result;
				}
				_g_object_unref0 (variant);
			}
		}
	}
	_tmp12_ = compatible;
	_tmp13_ = proton_plus_models_variant_selector_find_native_aarch64_variant ((GeeIterable*) _tmp12_, capabilities, FALSE);
	native_aarch64 = _tmp13_;
	_tmp14_ = native_aarch64;
	if (_tmp14_ != NULL) {
		result = native_aarch64;
		_g_object_unref0 (compatible);
		return result;
	}
	{
		GeeLinkedList* _variant_list = NULL;
		GeeLinkedList* _tmp15_;
		gint _variant_size = 0;
		GeeLinkedList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		gint _variant_index = 0;
		_tmp15_ = compatible;
		_variant_list = _tmp15_;
		_tmp16_ = _variant_list;
		_tmp17_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		_variant_size = _tmp18_;
		_variant_index = -1;
		while (TRUE) {
			gint _tmp19_;
			gint _tmp20_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeLinkedList* _tmp21_;
			gpointer _tmp22_;
			ProtonPlusModelsVariant* _tmp23_;
			gboolean _tmp24_;
			gboolean _tmp25_;
			_variant_index = _variant_index + 1;
			_tmp19_ = _variant_index;
			_tmp20_ = _variant_size;
			if (!(_tmp19_ < _tmp20_)) {
				break;
			}
			_tmp21_ = _variant_list;
			_tmp22_ = gee_abstract_list_get ((GeeAbstractList*) _tmp21_, _variant_index);
			variant = (ProtonPlusModelsVariant*) _tmp22_;
			_tmp23_ = variant;
			_tmp24_ = proton_plus_models_variant_get_is_default (_tmp23_);
			_tmp25_ = _tmp24_;
			if (_tmp25_) {
				result = variant;
				_g_object_unref0 (native_aarch64);
				_g_object_unref0 (compatible);
				return result;
			}
			_g_object_unref0 (variant);
		}
	}
	_tmp27_ = compatible;
	_tmp28_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp27_);
	_tmp29_ = _tmp28_;
	if (_tmp29_ > 0) {
		GeeLinkedList* _tmp30_;
		gpointer _tmp31_;
		_tmp30_ = compatible;
		_tmp31_ = gee_abstract_list_get ((GeeAbstractList*) _tmp30_, 0);
		_g_object_unref0 (_tmp26_);
		_tmp26_ = (ProtonPlusModelsVariant*) _tmp31_;
	} else {
		_g_object_unref0 (_tmp26_);
		_tmp26_ = NULL;
	}
	_tmp32_ = _tmp26_;
	_tmp26_ = NULL;
	result = _tmp32_;
	_g_object_unref0 (_tmp26_);
	_g_object_unref0 (native_aarch64);
	_g_object_unref0 (compatible);
	return result;
}

gboolean
proton_plus_models_variant_selector_should_show_dropdown (GeeCollection* displayed_variants)
{
	gint _tmp0_;
	gint _tmp1_;
	gboolean result;
	g_return_val_if_fail (displayed_variants != NULL, FALSE);
	_tmp0_ = gee_collection_get_size (displayed_variants);
	_tmp1_ = _tmp0_;
	result = _tmp1_ >= 2;
	return result;
}

ProtonPlusModelsVariant*
proton_plus_models_variant_selector_variant_at_display_index (GeeList* displayed_variants,
                                                              gint index)
{
	ProtonPlusModelsVariant* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	ProtonPlusModelsVariant* _tmp5_;
	ProtonPlusModelsVariant* result;
	g_return_val_if_fail (displayed_variants != NULL, NULL);
	if (index >= 0) {
		gint _tmp2_;
		gint _tmp3_;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) displayed_variants);
		_tmp3_ = _tmp2_;
		_tmp1_ = index < _tmp3_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gpointer _tmp4_;
		_tmp4_ = gee_list_get (displayed_variants, index);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = (ProtonPlusModelsVariant*) _tmp4_;
	} else {
		_g_object_unref0 (_tmp0_);
		_tmp0_ = NULL;
	}
	_tmp5_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp5_;
	_g_object_unref0 (_tmp0_);
	return result;
}

ProtonPlusModelsVariant*
proton_plus_models_variant_selector_resolve_release_variant (ProtonPlusModelsRelease* release,
                                                             ProtonPlusModelsVariant* selected_variant,
                                                             ProtonPlusModelsCpuCapabilities* capabilities,
                                                             gboolean allow_compatible_default_fallback)
{
	ProtonPlusModelsVariant* matching = NULL;
	ProtonPlusModelsVariant* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	ProtonPlusModelsVariant* _tmp3_;
	ProtonPlusModelsVariant* result;
	g_return_val_if_fail (release != NULL, NULL);
	g_return_val_if_fail (capabilities != NULL, NULL);
	if (selected_variant == NULL) {
		result = NULL;
		return result;
	}
	_tmp0_ = proton_plus_models_variant_selector_find_matching_release_variant (release, selected_variant);
	matching = _tmp0_;
	_tmp3_ = matching;
	if (_tmp3_ != NULL) {
		ProtonPlusModelsVariant* _tmp4_;
		_tmp4_ = matching;
		_tmp2_ = proton_plus_models_variant_selector_has_download_url (_tmp4_);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		ProtonPlusModelsVariant* _tmp5_;
		_tmp5_ = matching;
		_tmp1_ = proton_plus_models_variant_is_compatible_with (_tmp5_, capabilities);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		result = matching;
		return result;
	}
	if (!allow_compatible_default_fallback) {
		result = NULL;
		_g_object_unref0 (matching);
		return result;
	}
	{
		GeeLinkedList* _variant_list = NULL;
		GeeLinkedList* _tmp6_;
		GeeLinkedList* _tmp7_;
		gint _variant_size = 0;
		GeeLinkedList* _tmp8_;
		gint _tmp9_;
		gint _tmp10_;
		gint _variant_index = 0;
		_tmp6_ = proton_plus_models_release_get_variants (release);
		_tmp7_ = _tmp6_;
		_variant_list = _tmp7_;
		_tmp8_ = _variant_list;
		_tmp9_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp8_);
		_tmp10_ = _tmp9_;
		_variant_size = _tmp10_;
		_variant_index = -1;
		while (TRUE) {
			gint _tmp11_;
			gint _tmp12_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeLinkedList* _tmp13_;
			gpointer _tmp14_;
			gboolean _tmp15_ = FALSE;
			gboolean _tmp16_ = FALSE;
			ProtonPlusModelsVariant* _tmp17_;
			gboolean _tmp18_;
			gboolean _tmp19_;
			_variant_index = _variant_index + 1;
			_tmp11_ = _variant_index;
			_tmp12_ = _variant_size;
			if (!(_tmp11_ < _tmp12_)) {
				break;
			}
			_tmp13_ = _variant_list;
			_tmp14_ = gee_abstract_list_get ((GeeAbstractList*) _tmp13_, _variant_index);
			variant = (ProtonPlusModelsVariant*) _tmp14_;
			_tmp17_ = variant;
			_tmp18_ = proton_plus_models_variant_get_is_default (_tmp17_);
			_tmp19_ = _tmp18_;
			if (_tmp19_) {
				ProtonPlusModelsVariant* _tmp20_;
				_tmp20_ = variant;
				_tmp16_ = proton_plus_models_variant_selector_has_download_url (_tmp20_);
			} else {
				_tmp16_ = FALSE;
			}
			if (_tmp16_) {
				ProtonPlusModelsVariant* _tmp21_;
				_tmp21_ = variant;
				_tmp15_ = proton_plus_models_variant_is_compatible_with (_tmp21_, capabilities);
			} else {
				_tmp15_ = FALSE;
			}
			if (_tmp15_) {
				result = variant;
				_g_object_unref0 (matching);
				return result;
			}
			_g_object_unref0 (variant);
		}
	}
	result = NULL;
	_g_object_unref0 (matching);
	return result;
}

ProtonPlusModelsInstallationVariantResolution*
proton_plus_models_variant_selector_resolve_installation_variant (ProtonPlusModelsRelease* release,
                                                                  const gchar* selected_variant_id,
                                                                  const gchar* selected_variant_name,
                                                                  ProtonPlusModelsCpuCapabilities* capabilities)
{
	gboolean _tmp0_ = FALSE;
	gboolean has_id = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean has_name = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean explicit_selection = FALSE;
	ProtonPlusModelsVariant* matching = NULL;
	gboolean _tmp4_ = FALSE;
	ProtonPlusModelsVariant* _tmp5_;
	ProtonPlusModelsVariant* native_aarch64 = NULL;
	GeeLinkedList* _tmp17_;
	GeeLinkedList* _tmp18_;
	ProtonPlusModelsVariant* _tmp19_;
	ProtonPlusModelsVariant* _tmp20_;
	ProtonPlusModelsInstallationVariantResolution* _tmp55_;
	ProtonPlusModelsInstallationVariantResolution* result;
	g_return_val_if_fail (release != NULL, NULL);
	g_return_val_if_fail (capabilities != NULL, NULL);
	if (selected_variant_id != NULL) {
		_tmp0_ = g_strcmp0 (selected_variant_id, "") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	has_id = _tmp0_;
	if (selected_variant_name != NULL) {
		_tmp1_ = g_strcmp0 (selected_variant_name, "") != 0;
	} else {
		_tmp1_ = FALSE;
	}
	has_name = _tmp1_;
	if (has_id) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = has_name;
	}
	explicit_selection = _tmp2_;
	matching = NULL;
	if (has_id) {
		ProtonPlusModelsVariant* _tmp3_;
		_tmp3_ = proton_plus_models_variant_selector_find_release_variant_by_id (release, (const gchar*) selected_variant_id);
		_g_object_unref0 (matching);
		matching = _tmp3_;
	}
	_tmp5_ = matching;
	if (_tmp5_ == NULL) {
		_tmp4_ = has_name;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		ProtonPlusModelsVariant* _tmp6_;
		_tmp6_ = proton_plus_models_variant_selector_find_release_variant_by_name (release, (const gchar*) selected_variant_name);
		_g_object_unref0 (matching);
		matching = _tmp6_;
	}
	if (explicit_selection) {
		gboolean _tmp7_ = FALSE;
		gboolean _tmp8_ = FALSE;
		ProtonPlusModelsVariant* _tmp9_;
		ProtonPlusModelsVariant* _tmp15_;
		ProtonPlusModelsInstallationVariantResolution* _tmp16_;
		_tmp9_ = matching;
		if (_tmp9_ != NULL) {
			ProtonPlusModelsVariant* _tmp10_;
			_tmp10_ = matching;
			_tmp8_ = proton_plus_models_variant_selector_has_download_url (_tmp10_);
		} else {
			_tmp8_ = FALSE;
		}
		if (_tmp8_) {
			ProtonPlusModelsVariant* _tmp11_;
			_tmp11_ = matching;
			_tmp7_ = proton_plus_models_variant_is_compatible_with (_tmp11_, capabilities);
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			ProtonPlusModelsVariant* _tmp12_;
			ProtonPlusModelsVariant* _tmp13_;
			ProtonPlusModelsInstallationVariantResolution* _tmp14_;
			_tmp12_ = matching;
			_tmp13_ = matching;
			_tmp14_ = proton_plus_models_installation_variant_resolution_new (_tmp12_, _tmp13_, TRUE);
			result = _tmp14_;
			_g_object_unref0 (matching);
			return result;
		}
		_tmp15_ = matching;
		_tmp16_ = proton_plus_models_installation_variant_resolution_new (NULL, _tmp15_, TRUE);
		result = _tmp16_;
		_g_object_unref0 (matching);
		return result;
	}
	_tmp17_ = proton_plus_models_release_get_variants (release);
	_tmp18_ = _tmp17_;
	_tmp19_ = proton_plus_models_variant_selector_find_native_aarch64_variant ((GeeIterable*) _tmp18_, capabilities, TRUE);
	native_aarch64 = _tmp19_;
	_tmp20_ = native_aarch64;
	if (_tmp20_ != NULL) {
		ProtonPlusModelsVariant* _tmp21_;
		ProtonPlusModelsInstallationVariantResolution* _tmp22_;
		_tmp21_ = native_aarch64;
		_tmp22_ = proton_plus_models_installation_variant_resolution_new (_tmp21_, NULL, FALSE);
		result = _tmp22_;
		_g_object_unref0 (native_aarch64);
		_g_object_unref0 (matching);
		return result;
	}
	{
		GeeLinkedList* _variant_list = NULL;
		GeeLinkedList* _tmp23_;
		GeeLinkedList* _tmp24_;
		gint _variant_size = 0;
		GeeLinkedList* _tmp25_;
		gint _tmp26_;
		gint _tmp27_;
		gint _variant_index = 0;
		_tmp23_ = proton_plus_models_release_get_variants (release);
		_tmp24_ = _tmp23_;
		_variant_list = _tmp24_;
		_tmp25_ = _variant_list;
		_tmp26_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp25_);
		_tmp27_ = _tmp26_;
		_variant_size = _tmp27_;
		_variant_index = -1;
		while (TRUE) {
			gint _tmp28_;
			gint _tmp29_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeLinkedList* _tmp30_;
			gpointer _tmp31_;
			gboolean _tmp32_ = FALSE;
			gboolean _tmp33_ = FALSE;
			ProtonPlusModelsVariant* _tmp34_;
			gboolean _tmp35_;
			gboolean _tmp36_;
			_variant_index = _variant_index + 1;
			_tmp28_ = _variant_index;
			_tmp29_ = _variant_size;
			if (!(_tmp28_ < _tmp29_)) {
				break;
			}
			_tmp30_ = _variant_list;
			_tmp31_ = gee_abstract_list_get ((GeeAbstractList*) _tmp30_, _variant_index);
			variant = (ProtonPlusModelsVariant*) _tmp31_;
			_tmp34_ = variant;
			_tmp35_ = proton_plus_models_variant_get_is_default (_tmp34_);
			_tmp36_ = _tmp35_;
			if (_tmp36_) {
				ProtonPlusModelsVariant* _tmp37_;
				_tmp37_ = variant;
				_tmp33_ = proton_plus_models_variant_selector_has_download_url (_tmp37_);
			} else {
				_tmp33_ = FALSE;
			}
			if (_tmp33_) {
				ProtonPlusModelsVariant* _tmp38_;
				_tmp38_ = variant;
				_tmp32_ = proton_plus_models_variant_is_compatible_with (_tmp38_, capabilities);
			} else {
				_tmp32_ = FALSE;
			}
			if (_tmp32_) {
				ProtonPlusModelsVariant* _tmp39_;
				ProtonPlusModelsInstallationVariantResolution* _tmp40_;
				_tmp39_ = variant;
				_tmp40_ = proton_plus_models_installation_variant_resolution_new (_tmp39_, NULL, FALSE);
				result = _tmp40_;
				_g_object_unref0 (variant);
				_g_object_unref0 (native_aarch64);
				_g_object_unref0 (matching);
				return result;
			}
			_g_object_unref0 (variant);
		}
	}
	{
		GeeLinkedList* _variant_list = NULL;
		GeeLinkedList* _tmp41_;
		GeeLinkedList* _tmp42_;
		gint _variant_size = 0;
		GeeLinkedList* _tmp43_;
		gint _tmp44_;
		gint _tmp45_;
		gint _variant_index = 0;
		_tmp41_ = proton_plus_models_release_get_variants (release);
		_tmp42_ = _tmp41_;
		_variant_list = _tmp42_;
		_tmp43_ = _variant_list;
		_tmp44_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp43_);
		_tmp45_ = _tmp44_;
		_variant_size = _tmp45_;
		_variant_index = -1;
		while (TRUE) {
			gint _tmp46_;
			gint _tmp47_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeLinkedList* _tmp48_;
			gpointer _tmp49_;
			gboolean _tmp50_ = FALSE;
			ProtonPlusModelsVariant* _tmp51_;
			_variant_index = _variant_index + 1;
			_tmp46_ = _variant_index;
			_tmp47_ = _variant_size;
			if (!(_tmp46_ < _tmp47_)) {
				break;
			}
			_tmp48_ = _variant_list;
			_tmp49_ = gee_abstract_list_get ((GeeAbstractList*) _tmp48_, _variant_index);
			variant = (ProtonPlusModelsVariant*) _tmp49_;
			_tmp51_ = variant;
			if (proton_plus_models_variant_selector_has_download_url (_tmp51_)) {
				ProtonPlusModelsVariant* _tmp52_;
				_tmp52_ = variant;
				_tmp50_ = proton_plus_models_variant_is_compatible_with (_tmp52_, capabilities);
			} else {
				_tmp50_ = FALSE;
			}
			if (_tmp50_) {
				ProtonPlusModelsVariant* _tmp53_;
				ProtonPlusModelsInstallationVariantResolution* _tmp54_;
				_tmp53_ = variant;
				_tmp54_ = proton_plus_models_installation_variant_resolution_new (_tmp53_, NULL, FALSE);
				result = _tmp54_;
				_g_object_unref0 (variant);
				_g_object_unref0 (native_aarch64);
				_g_object_unref0 (matching);
				return result;
			}
			_g_object_unref0 (variant);
		}
	}
	_tmp55_ = proton_plus_models_installation_variant_resolution_new (NULL, NULL, FALSE);
	result = _tmp55_;
	_g_object_unref0 (native_aarch64);
	_g_object_unref0 (matching);
	return result;
}

static ProtonPlusModelsVariant*
proton_plus_models_variant_selector_find_native_aarch64_variant (GeeIterable* variants,
                                                                 ProtonPlusModelsCpuCapabilities* capabilities,
                                                                 gboolean require_download_url)
{
	ProtonPlusModelsCpuArchitecture _tmp0_;
	ProtonPlusModelsCpuArchitecture _tmp1_;
	ProtonPlusModelsVariant* result;
	g_return_val_if_fail (variants != NULL, NULL);
	g_return_val_if_fail (capabilities != NULL, NULL);
	_tmp0_ = proton_plus_models_cpu_capabilities_get_architecture (capabilities);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != PROTON_PLUS_MODELS_CPU_ARCHITECTURE_AARCH64) {
		result = NULL;
		return result;
	}
	{
		GeeIterator* _variant_it = NULL;
		GeeIterator* _tmp2_;
		_tmp2_ = gee_iterable_iterator (variants);
		_variant_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			gboolean _tmp6_ = FALSE;
			gboolean _tmp7_ = FALSE;
			ProtonPlusModelsVariant* _tmp8_;
			ProtonPlusModelsVariantCompatibility* _tmp9_;
			ProtonPlusModelsVariantCompatibility* _tmp10_;
			_tmp3_ = _variant_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _variant_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			variant = (ProtonPlusModelsVariant*) _tmp5_;
			_tmp8_ = variant;
			_tmp9_ = proton_plus_models_variant_get_compatibility (_tmp8_);
			_tmp10_ = _tmp9_;
			if (proton_plus_models_variant_compatibility_explicitly_supports_architecture (_tmp10_, PROTON_PLUS_MODELS_CPU_ARCHITECTURE_AARCH64)) {
				ProtonPlusModelsVariant* _tmp11_;
				_tmp11_ = variant;
				_tmp7_ = proton_plus_models_variant_is_compatible_with (_tmp11_, capabilities);
			} else {
				_tmp7_ = FALSE;
			}
			if (_tmp7_) {
				gboolean _tmp12_ = FALSE;
				if (!require_download_url) {
					_tmp12_ = TRUE;
				} else {
					ProtonPlusModelsVariant* _tmp13_;
					_tmp13_ = variant;
					_tmp12_ = proton_plus_models_variant_selector_has_download_url (_tmp13_);
				}
				_tmp6_ = _tmp12_;
			} else {
				_tmp6_ = FALSE;
			}
			if (_tmp6_) {
				result = variant;
				_g_object_unref0 (_variant_it);
				return result;
			}
			_g_object_unref0 (variant);
		}
		_g_object_unref0 (_variant_it);
	}
	result = NULL;
	return result;
}

static ProtonPlusModelsVariant*
proton_plus_models_variant_selector_find_matching_release_variant (ProtonPlusModelsRelease* release,
                                                                   ProtonPlusModelsVariant* selected_variant)
{
	ProtonPlusModelsVariant* by_id = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	ProtonPlusModelsVariant* _tmp2_;
	ProtonPlusModelsVariant* _tmp3_ = NULL;
	ProtonPlusModelsVariant* _tmp4_;
	ProtonPlusModelsVariant* _tmp5_;
	ProtonPlusModelsVariant* _tmp9_;
	ProtonPlusModelsVariant* result;
	g_return_val_if_fail (release != NULL, NULL);
	g_return_val_if_fail (selected_variant != NULL, NULL);
	_tmp0_ = proton_plus_models_variant_get_id (selected_variant);
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_models_variant_selector_find_release_variant_by_id (release, _tmp1_);
	by_id = _tmp2_;
	_tmp4_ = by_id;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_tmp3_ = _tmp5_;
	if (_tmp3_ == NULL) {
		const gchar* _tmp6_;
		const gchar* _tmp7_;
		ProtonPlusModelsVariant* _tmp8_;
		_tmp6_ = proton_plus_models_variant_get_name (selected_variant);
		_tmp7_ = _tmp6_;
		_tmp8_ = proton_plus_models_variant_selector_find_release_variant_by_name (release, _tmp7_);
		_g_object_unref0 (_tmp3_);
		_tmp3_ = _tmp8_;
	}
	_tmp9_ = _tmp3_;
	_tmp3_ = NULL;
	result = _tmp9_;
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (by_id);
	return result;
}

static ProtonPlusModelsVariant*
proton_plus_models_variant_selector_find_release_variant_by_id (ProtonPlusModelsRelease* release,
                                                                const gchar* id)
{
	ProtonPlusModelsVariant* result;
	g_return_val_if_fail (release != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	{
		GeeLinkedList* _variant_list = NULL;
		GeeLinkedList* _tmp0_;
		GeeLinkedList* _tmp1_;
		gint _variant_size = 0;
		GeeLinkedList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _variant_index = 0;
		_tmp0_ = proton_plus_models_release_get_variants (release);
		_tmp1_ = _tmp0_;
		_variant_list = _tmp1_;
		_tmp2_ = _variant_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_variant_size = _tmp4_;
		_variant_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeLinkedList* _tmp7_;
			gpointer _tmp8_;
			ProtonPlusModelsVariant* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			_variant_index = _variant_index + 1;
			_tmp5_ = _variant_index;
			_tmp6_ = _variant_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _variant_list;
			_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _variant_index);
			variant = (ProtonPlusModelsVariant*) _tmp8_;
			_tmp9_ = variant;
			_tmp10_ = proton_plus_models_variant_get_id (_tmp9_);
			_tmp11_ = _tmp10_;
			if (g_strcmp0 (_tmp11_, id) == 0) {
				result = variant;
				return result;
			}
			_g_object_unref0 (variant);
		}
	}
	result = NULL;
	return result;
}

static ProtonPlusModelsVariant*
proton_plus_models_variant_selector_find_release_variant_by_name (ProtonPlusModelsRelease* release,
                                                                  const gchar* name)
{
	ProtonPlusModelsVariant* result;
	g_return_val_if_fail (release != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	{
		GeeLinkedList* _variant_list = NULL;
		GeeLinkedList* _tmp0_;
		GeeLinkedList* _tmp1_;
		gint _variant_size = 0;
		GeeLinkedList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _variant_index = 0;
		_tmp0_ = proton_plus_models_release_get_variants (release);
		_tmp1_ = _tmp0_;
		_variant_list = _tmp1_;
		_tmp2_ = _variant_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_variant_size = _tmp4_;
		_variant_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			ProtonPlusModelsVariant* variant = NULL;
			GeeLinkedList* _tmp7_;
			gpointer _tmp8_;
			ProtonPlusModelsVariant* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			_variant_index = _variant_index + 1;
			_tmp5_ = _variant_index;
			_tmp6_ = _variant_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _variant_list;
			_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _variant_index);
			variant = (ProtonPlusModelsVariant*) _tmp8_;
			_tmp9_ = variant;
			_tmp10_ = proton_plus_models_variant_get_name (_tmp9_);
			_tmp11_ = _tmp10_;
			if (g_strcmp0 (_tmp11_, name) == 0) {
				result = variant;
				return result;
			}
			_g_object_unref0 (variant);
		}
	}
	result = NULL;
	return result;
}

static gboolean
proton_plus_models_variant_selector_has_download_url (ProtonPlusModelsVariant* variant)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	if (variant != NULL) {
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		_tmp2_ = proton_plus_models_variant_get_download_url (variant);
		_tmp3_ = _tmp2_;
		_tmp1_ = _tmp3_ != NULL;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		_tmp4_ = proton_plus_models_variant_get_download_url (variant);
		_tmp5_ = _tmp4_;
		_tmp0_ = g_strcmp0 (_tmp5_, "") != 0;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

ProtonPlusModelsVariantSelector*
proton_plus_models_variant_selector_construct (GType object_type)
{
	ProtonPlusModelsVariantSelector * self = NULL;
	self = (ProtonPlusModelsVariantSelector*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusModelsVariantSelector*
proton_plus_models_variant_selector_new (void)
{
	return proton_plus_models_variant_selector_construct (PROTON_PLUS_MODELS_TYPE_VARIANT_SELECTOR);
}

static void
proton_plus_models_variant_selector_class_init (ProtonPlusModelsVariantSelectorClass * klass,
                                                gpointer klass_data)
{
	proton_plus_models_variant_selector_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_models_variant_selector_instance_init (ProtonPlusModelsVariantSelector * self,
                                                   gpointer klass)
{
}

static GType
proton_plus_models_variant_selector_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusModelsVariantSelectorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_models_variant_selector_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusModelsVariantSelector), 0, (GInstanceInitFunc) proton_plus_models_variant_selector_instance_init, NULL };
	GType proton_plus_models_variant_selector_type_id;
	proton_plus_models_variant_selector_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusModelsVariantSelector", &g_define_type_info, 0);
	return proton_plus_models_variant_selector_type_id;
}

GType
proton_plus_models_variant_selector_get_type (void)
{
	static volatile gsize proton_plus_models_variant_selector_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_models_variant_selector_type_id__once)) {
		GType proton_plus_models_variant_selector_type_id;
		proton_plus_models_variant_selector_type_id = proton_plus_models_variant_selector_get_type_once ();
		g_once_init_leave (&proton_plus_models_variant_selector_type_id__once, proton_plus_models_variant_selector_type_id);
	}
	return proton_plus_models_variant_selector_type_id__once;
}

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;
}

