/* steam-restart-manager.c generated by valac 0.56.19, the Vala compiler
 * generated from steam-restart-manager.vala, do not modify */

#include "protonplus_core.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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_SERVICES_STEAM_RESTART_MANAGER_0_PROPERTY,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_PERSISTENCE_ERROR_PROPERTY,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_LOAD_ERROR_PROPERTY,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_IS_OBSERVING_PROPERTY,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_services_steam_restart_manager_properties[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_BECAME_REQUIRED_SIGNAL,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_REQUIREMENT_SATISFIED_SIGNAL,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PERSISTENCE_FAILED_SIGNAL,
	PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_NUM_SIGNALS
};
static guint proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_NUM_SIGNALS] = {0};

struct _ProtonPlusServicesSteamRestartManagerPrivate {
	ProtonPlusServicesSteamSessionService* session_service;
	ProtonPlusServicesSteamRestartStateStore* state_store;
	GeeHashMap* pending;
	GeeHashMap* targets;
	ProtonPlusServicesSteamConfigurationReconciler* configuration_reconciler;
	gulong state_changed_handler_id;
	gboolean observation_started;
	gchar* _last_persistence_error;
	gchar* _last_load_error;
};

static gint ProtonPlusServicesSteamRestartManager_private_offset;
static gpointer proton_plus_services_steam_restart_manager_parent_class = NULL;
static ProtonPlusServicesSteamChangeRecorderIface * proton_plus_services_steam_restart_manager_proton_plus_services_steam_change_recorder_parent_iface = NULL;

static void proton_plus_services_steam_restart_manager_set_last_load_error (ProtonPlusServicesSteamRestartManager* self,
                                                                     const gchar* value);
static void proton_plus_services_steam_restart_manager_add_loaded_record (ProtonPlusServicesSteamRestartManager* self,
                                                                   ProtonPlusModelsSteamRestartPendingRecord* record);
static ProtonPlusServicesSteamRestartRecordResult proton_plus_services_steam_restart_manager_real_record (ProtonPlusServicesSteamChangeRecorder* base,
                                                                                                   ProtonPlusModelsSteamChangeReceipt* receipt);
static gboolean proton_plus_services_steam_restart_manager_is_confirmed_stopped (ProtonPlusServicesSteamRestartManager* self,
                                                                          ProtonPlusServicesSteamSessionSnapshot* snapshot);
static ProtonPlusModelsSteamSessionIdentity* proton_plus_services_steam_restart_manager_identity_from_snapshot (ProtonPlusServicesSteamRestartManager* self,
                                                                                                         ProtonPlusModelsSteamRestartTarget* target,
                                                                                                         ProtonPlusServicesSteamSessionSnapshot* snapshot);
static gboolean proton_plus_services_steam_restart_manager_persist (ProtonPlusServicesSteamRestartManager* self);
static ProtonPlusModelsSteamRestartPendingRecord* proton_plus_services_steam_restart_manager_updated_record (ProtonPlusServicesSteamRestartManager* self,
                                                                                                      ProtonPlusModelsSteamRestartPendingRecord* old,
                                                                                                      ProtonPlusModelsSteamChangeReceipt* receipt,
                                                                                                      ProtonPlusModelsSteamSessionIdentity* session);
static void proton_plus_services_steam_restart_manager_watch_target (ProtonPlusServicesSteamRestartManager* self,
                                                              ProtonPlusModelsSteamRestartTarget* target);
static void __lambda12_ (ProtonPlusServicesSteamRestartManager* self,
                  ProtonPlusModelsSteamRestartTarget* target,
                  ProtonPlusServicesSteamSessionSnapshot* snapshot);
static void ___lambda12__proton_plus_services_steam_session_service_state_changed (ProtonPlusServicesSteamSessionService* _sender,
                                                                            ProtonPlusModelsSteamRestartTarget* target,
                                                                            ProtonPlusServicesSteamSessionSnapshot* snapshot,
                                                                            gpointer self);
static void proton_plus_services_steam_restart_manager_reconcile_startup_target (ProtonPlusServicesSteamRestartManager* self,
                                                                          ProtonPlusModelsSteamRestartTarget* target);
static void proton_plus_services_steam_restart_manager_mark_stop_observed (ProtonPlusServicesSteamRestartManager* self,
                                                                    ProtonPlusModelsSteamRestartTarget* target);
static gboolean proton_plus_services_steam_restart_manager_clear_records (ProtonPlusServicesSteamRestartManager* self,
                                                                   GeeCollection* records);
static void proton_plus_services_steam_restart_manager_set_last_persistence_error (ProtonPlusServicesSteamRestartManager* self,
                                                                            const gchar* value);
static void proton_plus_services_steam_restart_manager_finalize (GObject * obj);
static GType proton_plus_services_steam_restart_manager_get_type_once (void);
static void _vala_proton_plus_services_steam_restart_manager_get_property (GObject * object,
                                                                    guint property_id,
                                                                    GValue * value,
                                                                    GParamSpec * pspec);
static void _vala_proton_plus_services_steam_restart_manager_set_property (GObject * object,
                                                                    guint property_id,
                                                                    const GValue * value,
                                                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
proton_plus_services_steam_restart_record_result_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_ADDED, "PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_ADDED", "added"}, {PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_UPDATED, "PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_UPDATED", "updated"}, {PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_REQUIREMENT_CLEARED, "PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_REQUIREMENT_CLEARED", "requirement-cleared"}, {PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_UNCHANGED, "PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_UNCHANGED", "unchanged"}, {PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_ALREADY_SATISFIED, "PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_ALREADY_SATISFIED", "already-satisfied"}, {PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_PERSISTENCE_FAILED, "PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_PERSISTENCE_FAILED", "persistence-failed"}, {0, NULL, NULL}};
	GType proton_plus_services_steam_restart_record_result_type_id;
	proton_plus_services_steam_restart_record_result_type_id = g_enum_register_static ("ProtonPlusServicesSteamRestartRecordResult", values);
	return proton_plus_services_steam_restart_record_result_type_id;
}

GType
proton_plus_services_steam_restart_record_result_get_type (void)
{
	static volatile gsize proton_plus_services_steam_restart_record_result_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_services_steam_restart_record_result_type_id__once)) {
		GType proton_plus_services_steam_restart_record_result_type_id;
		proton_plus_services_steam_restart_record_result_type_id = proton_plus_services_steam_restart_record_result_get_type_once ();
		g_once_init_leave (&proton_plus_services_steam_restart_record_result_type_id__once, proton_plus_services_steam_restart_record_result_type_id);
	}
	return proton_plus_services_steam_restart_record_result_type_id__once;
}

static inline gpointer
proton_plus_services_steam_restart_manager_get_instance_private (ProtonPlusServicesSteamRestartManager* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusServicesSteamRestartManager_private_offset);
}

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

ProtonPlusServicesSteamRestartManager*
proton_plus_services_steam_restart_manager_construct (GType object_type,
                                                      ProtonPlusServicesSteamSessionService* session_service,
                                                      ProtonPlusServicesSteamRestartStateStore* state_store,
                                                      ProtonPlusServicesSteamConfigurationReconciler* configuration_reconciler)
{
	ProtonPlusServicesSteamRestartManager * self = NULL;
	ProtonPlusServicesSteamSessionService* _tmp0_;
	ProtonPlusServicesSteamRestartStateStore* _tmp1_;
	ProtonPlusServicesSteamConfigurationReconciler* _tmp2_;
	ProtonPlusServicesSteamRestartStateLoadResult* loaded = NULL;
	ProtonPlusServicesSteamRestartStateLoadResult* _tmp3_;
	ProtonPlusServicesSteamRestartStateLoadResult* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	g_return_val_if_fail (session_service != NULL, NULL);
	g_return_val_if_fail (state_store != NULL, NULL);
	self = (ProtonPlusServicesSteamRestartManager*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (session_service);
	_g_object_unref0 (self->priv->session_service);
	self->priv->session_service = _tmp0_;
	_tmp1_ = _g_object_ref0 (state_store);
	_g_object_unref0 (self->priv->state_store);
	self->priv->state_store = _tmp1_;
	_tmp2_ = _g_object_ref0 (configuration_reconciler);
	_g_object_unref0 (self->priv->configuration_reconciler);
	self->priv->configuration_reconciler = _tmp2_;
	_tmp3_ = proton_plus_services_steam_restart_state_store_load (state_store);
	loaded = _tmp3_;
	_tmp4_ = loaded;
	_tmp5_ = proton_plus_services_steam_restart_state_load_result_get_error (_tmp4_);
	_tmp6_ = _tmp5_;
	proton_plus_services_steam_restart_manager_set_last_load_error (self, _tmp6_);
	{
		GeeList* _record_list = NULL;
		ProtonPlusServicesSteamRestartStateLoadResult* _tmp7_;
		GeeList* _tmp8_;
		GeeList* _tmp9_;
		gint _record_size = 0;
		GeeList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		gint _record_index = 0;
		_tmp7_ = loaded;
		_tmp8_ = proton_plus_services_steam_restart_state_load_result_get_records (_tmp7_);
		_tmp9_ = _tmp8_;
		_record_list = _tmp9_;
		_tmp10_ = _record_list;
		_tmp11_ = gee_collection_get_size ((GeeCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_record_size = _tmp12_;
		_record_index = -1;
		while (TRUE) {
			gint _tmp13_;
			gint _tmp14_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeList* _tmp15_;
			gpointer _tmp16_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp17_;
			_record_index = _record_index + 1;
			_tmp13_ = _record_index;
			_tmp14_ = _record_size;
			if (!(_tmp13_ < _tmp14_)) {
				break;
			}
			_tmp15_ = _record_list;
			_tmp16_ = gee_list_get (_tmp15_, _record_index);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp16_;
			_tmp17_ = record;
			proton_plus_services_steam_restart_manager_add_loaded_record (self, _tmp17_);
			_g_object_unref0 (record);
		}
	}
	_g_object_unref0 (loaded);
	return self;
}

ProtonPlusServicesSteamRestartManager*
proton_plus_services_steam_restart_manager_new (ProtonPlusServicesSteamSessionService* session_service,
                                                ProtonPlusServicesSteamRestartStateStore* state_store,
                                                ProtonPlusServicesSteamConfigurationReconciler* configuration_reconciler)
{
	return proton_plus_services_steam_restart_manager_construct (PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, session_service, state_store, configuration_reconciler);
}

void
proton_plus_services_steam_restart_manager_configure_configuration_reconciler (ProtonPlusServicesSteamRestartManager* self,
                                                                               ProtonPlusServicesSteamConfigurationReconciler* reconciler)
{
	ProtonPlusServicesSteamConfigurationReconciler* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (reconciler);
	_g_object_unref0 (self->priv->configuration_reconciler);
	self->priv->configuration_reconciler = _tmp0_;
}

gboolean
proton_plus_services_steam_restart_manager_has_pending_restarts (ProtonPlusServicesSteamRestartManager* self)
{
	GeeHashMap* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->pending;
	_tmp1_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_ > 0;
	return result;
}

gint
proton_plus_services_steam_restart_manager_pending_count (ProtonPlusServicesSteamRestartManager* self)
{
	GeeHashMap* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->priv->pending;
	_tmp1_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

gint
proton_plus_services_steam_restart_manager_pending_count_for_target (ProtonPlusServicesSteamRestartManager* self,
                                                                     ProtonPlusModelsSteamRestartTarget* target)
{
	gint count = 0;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (target != NULL, -1);
	count = 0;
	{
		GeeIterator* _record_it = NULL;
		GeeHashMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->pending;
		_tmp1_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_record_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp9_;
			ProtonPlusModelsSteamChangeReceipt* _tmp10_;
			ProtonPlusModelsSteamChangeReceipt* _tmp11_;
			ProtonPlusModelsSteamRestartTarget* _tmp12_;
			ProtonPlusModelsSteamRestartTarget* _tmp13_;
			const gchar* _tmp14_;
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			_tmp6_ = _record_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _record_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp8_;
			_tmp9_ = record;
			_tmp10_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = proton_plus_models_steam_change_receipt_get_target (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp14_ = proton_plus_models_steam_restart_target_get_id (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp16_ = proton_plus_models_steam_restart_target_get_id (target);
			_tmp17_ = _tmp16_;
			if (g_strcmp0 (_tmp15_, _tmp17_) == 0) {
				gint _tmp18_;
				_tmp18_ = count;
				count = _tmp18_ + 1;
			}
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_it);
	}
	result = count;
	return result;
}

GeeList*
proton_plus_services_steam_restart_manager_get_pending_changes (ProtonPlusServicesSteamRestartManager* self)
{
	GeeArrayList* copy = NULL;
	GeeArrayList* _tmp0_;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	copy = _tmp0_;
	{
		GeeIterator* _record_it = NULL;
		GeeHashMap* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeIterator* _tmp5_;
		GeeIterator* _tmp6_;
		_tmp1_ = self->priv->pending;
		_tmp2_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_record_it = _tmp6_;
		while (TRUE) {
			GeeIterator* _tmp7_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeIterator* _tmp8_;
			gpointer _tmp9_;
			GeeArrayList* _tmp10_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp11_;
			_tmp7_ = _record_it;
			if (!gee_iterator_next (_tmp7_)) {
				break;
			}
			_tmp8_ = _record_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp9_;
			_tmp10_ = copy;
			_tmp11_ = record;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp11_);
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_it);
	}
	result = (GeeList*) copy;
	return result;
}

GeeList*
proton_plus_services_steam_restart_manager_get_pending_changes_for_target (ProtonPlusServicesSteamRestartManager* self,
                                                                           ProtonPlusModelsSteamRestartTarget* target)
{
	GeeArrayList* copy = NULL;
	GeeArrayList* _tmp0_;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (target != NULL, NULL);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	copy = _tmp0_;
	{
		GeeIterator* _record_it = NULL;
		GeeHashMap* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeIterator* _tmp5_;
		GeeIterator* _tmp6_;
		_tmp1_ = self->priv->pending;
		_tmp2_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_record_it = _tmp6_;
		while (TRUE) {
			GeeIterator* _tmp7_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeIterator* _tmp8_;
			gpointer _tmp9_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp10_;
			ProtonPlusModelsSteamChangeReceipt* _tmp11_;
			ProtonPlusModelsSteamChangeReceipt* _tmp12_;
			ProtonPlusModelsSteamRestartTarget* _tmp13_;
			ProtonPlusModelsSteamRestartTarget* _tmp14_;
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			_tmp7_ = _record_it;
			if (!gee_iterator_next (_tmp7_)) {
				break;
			}
			_tmp8_ = _record_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp9_;
			_tmp10_ = record;
			_tmp11_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = proton_plus_models_steam_change_receipt_get_target (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = proton_plus_models_steam_restart_target_get_id (_tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = proton_plus_models_steam_restart_target_get_id (target);
			_tmp18_ = _tmp17_;
			if (g_strcmp0 (_tmp16_, _tmp18_) == 0) {
				GeeArrayList* _tmp19_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp20_;
				_tmp19_ = copy;
				_tmp20_ = record;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp19_, _tmp20_);
			}
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_it);
	}
	result = (GeeList*) copy;
	return result;
}

ProtonPlusModelsSteamConfigurationIntent*
proton_plus_services_steam_restart_manager_get_pending_configuration_intent (ProtonPlusServicesSteamRestartManager* self,
                                                                             ProtonPlusModelsSteamRestartTarget* target,
                                                                             const gchar* resource_key)
{
	ProtonPlusModelsSteamConfigurationIntent* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (resource_key != NULL, NULL);
	{
		GeeIterator* _record_it = NULL;
		GeeHashMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->pending;
		_tmp1_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_record_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			gboolean _tmp9_ = FALSE;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp10_;
			ProtonPlusModelsSteamChangeReceipt* _tmp11_;
			ProtonPlusModelsSteamChangeReceipt* _tmp12_;
			ProtonPlusModelsSteamRestartTarget* _tmp13_;
			ProtonPlusModelsSteamRestartTarget* _tmp14_;
			const gchar* _tmp15_;
			const gchar* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			_tmp6_ = _record_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _record_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp8_;
			_tmp10_ = record;
			_tmp11_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp10_);
			_tmp12_ = _tmp11_;
			_tmp13_ = proton_plus_models_steam_change_receipt_get_target (_tmp12_);
			_tmp14_ = _tmp13_;
			_tmp15_ = proton_plus_models_steam_restart_target_get_id (_tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = proton_plus_models_steam_restart_target_get_id (target);
			_tmp18_ = _tmp17_;
			if (g_strcmp0 (_tmp16_, _tmp18_) == 0) {
				ProtonPlusModelsSteamRestartPendingRecord* _tmp19_;
				ProtonPlusModelsSteamChangeReceipt* _tmp20_;
				ProtonPlusModelsSteamChangeReceipt* _tmp21_;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				_tmp19_ = record;
				_tmp20_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp19_);
				_tmp21_ = _tmp20_;
				_tmp22_ = proton_plus_models_steam_change_receipt_get_resource_key (_tmp21_);
				_tmp23_ = _tmp22_;
				_tmp9_ = g_strcmp0 (_tmp23_, resource_key) == 0;
			} else {
				_tmp9_ = FALSE;
			}
			if (_tmp9_) {
				ProtonPlusModelsSteamRestartPendingRecord* _tmp24_;
				ProtonPlusModelsSteamChangeReceipt* _tmp25_;
				ProtonPlusModelsSteamChangeReceipt* _tmp26_;
				ProtonPlusModelsSteamConfigurationIntent* _tmp27_;
				ProtonPlusModelsSteamConfigurationIntent* _tmp28_;
				ProtonPlusModelsSteamConfigurationIntent* _tmp29_;
				_tmp24_ = record;
				_tmp25_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp24_);
				_tmp26_ = _tmp25_;
				_tmp27_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp26_);
				_tmp28_ = _tmp27_;
				_tmp29_ = _g_object_ref0 (_tmp28_);
				result = _tmp29_;
				_g_object_unref0 (record);
				_g_object_unref0 (_record_it);
				return result;
			}
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_it);
	}
	result = NULL;
	return result;
}

GeeList*
proton_plus_services_steam_restart_manager_get_pending_targets (ProtonPlusServicesSteamRestartManager* self)
{
	GeeArrayList* copy = NULL;
	GeeArrayList* _tmp0_;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_TARGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	copy = _tmp0_;
	{
		GeeIterator* _target_it = NULL;
		GeeHashMap* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeCollection* _tmp4_;
		GeeIterator* _tmp5_;
		GeeIterator* _tmp6_;
		_tmp1_ = self->priv->targets;
		_tmp2_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
		_tmp6_ = _tmp5_;
		_g_object_unref0 (_tmp4_);
		_target_it = _tmp6_;
		while (TRUE) {
			GeeIterator* _tmp7_;
			ProtonPlusModelsSteamRestartTarget* target = NULL;
			GeeIterator* _tmp8_;
			gpointer _tmp9_;
			GeeArrayList* _tmp10_;
			ProtonPlusModelsSteamRestartTarget* _tmp11_;
			_tmp7_ = _target_it;
			if (!gee_iterator_next (_tmp7_)) {
				break;
			}
			_tmp8_ = _target_it;
			_tmp9_ = gee_iterator_get (_tmp8_);
			target = (ProtonPlusModelsSteamRestartTarget*) _tmp9_;
			_tmp10_ = copy;
			_tmp11_ = target;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp11_);
			_g_object_unref0 (target);
		}
		_g_object_unref0 (_target_it);
	}
	result = (GeeList*) copy;
	return result;
}

static ProtonPlusServicesSteamRestartRecordResult
proton_plus_services_steam_restart_manager_real_record (ProtonPlusServicesSteamChangeRecorder* base,
                                                        ProtonPlusModelsSteamChangeReceipt* receipt)
{
	ProtonPlusServicesSteamRestartManager * self;
	ProtonPlusServicesSteamSessionSnapshot* snapshot = NULL;
	ProtonPlusServicesSteamSessionService* _tmp0_;
	ProtonPlusModelsSteamRestartTarget* _tmp1_;
	ProtonPlusModelsSteamRestartTarget* _tmp2_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp3_;
	ProtonPlusModelsSteamRestartTarget* _tmp4_;
	ProtonPlusModelsSteamRestartTarget* _tmp5_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp6_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp7_;
	gchar* key = NULL;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gboolean was_empty = FALSE;
	ProtonPlusModelsSteamRestartTarget* _tmp10_;
	ProtonPlusModelsSteamRestartTarget* _tmp11_;
	ProtonPlusModelsSteamRestartPendingRecord* existing = NULL;
	GeeHashMap* _tmp12_;
	const gchar* _tmp13_;
	gpointer _tmp14_;
	ProtonPlusModelsSteamSessionIdentity* stable_session = NULL;
	ProtonPlusModelsSteamRestartTarget* _tmp15_;
	ProtonPlusModelsSteamRestartTarget* _tmp16_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp17_;
	ProtonPlusModelsSteamSessionIdentity* _tmp18_;
	ProtonPlusModelsSteamChangeKind _tmp19_;
	ProtonPlusModelsSteamChangeKind _tmp20_;
	gboolean _tmp109_ = FALSE;
	gboolean _tmp110_ = FALSE;
	ProtonPlusModelsSteamRestartPendingRecord* _tmp111_;
	ProtonPlusModelsSteamRestartPendingRecord* _tmp317_;
	ProtonPlusModelsSteamRestartTarget* _tmp353_;
	ProtonPlusModelsSteamRestartTarget* _tmp354_;
	ProtonPlusServicesSteamRestartRecordResult _tmp357_ = 0;
	ProtonPlusModelsSteamRestartPendingRecord* _tmp358_;
	ProtonPlusServicesSteamRestartRecordResult result;
	self = (ProtonPlusServicesSteamRestartManager*) base;
	g_return_val_if_fail (receipt != NULL, 0);
	_tmp0_ = self->priv->session_service;
	_tmp1_ = proton_plus_models_steam_change_receipt_get_target (receipt);
	_tmp2_ = _tmp1_;
	_tmp3_ = proton_plus_services_steam_session_service_inspect (_tmp0_, _tmp2_);
	snapshot = _tmp3_;
	_tmp4_ = proton_plus_models_steam_change_receipt_get_target (receipt);
	_tmp5_ = _tmp4_;
	_tmp6_ = snapshot;
	proton_plus_services_steam_restart_manager_reconcile_snapshot (self, _tmp5_, _tmp6_);
	_tmp7_ = snapshot;
	if (proton_plus_services_steam_restart_manager_is_confirmed_stopped (self, _tmp7_)) {
		result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_ALREADY_SATISFIED;
		_g_object_unref0 (snapshot);
		return result;
	}
	_tmp8_ = proton_plus_models_steam_change_receipt_get_deduplication_key (receipt);
	_tmp9_ = _tmp8_;
	key = _tmp9_;
	_tmp10_ = proton_plus_models_steam_change_receipt_get_target (receipt);
	_tmp11_ = _tmp10_;
	was_empty = proton_plus_services_steam_restart_manager_pending_count_for_target (self, _tmp11_) == 0;
	_tmp12_ = self->priv->pending;
	_tmp13_ = key;
	_tmp14_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp12_, _tmp13_);
	existing = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp14_;
	_tmp15_ = proton_plus_models_steam_change_receipt_get_target (receipt);
	_tmp16_ = _tmp15_;
	_tmp17_ = snapshot;
	_tmp18_ = proton_plus_services_steam_restart_manager_identity_from_snapshot (self, _tmp16_, _tmp17_);
	stable_session = _tmp18_;
	_tmp19_ = proton_plus_models_steam_change_receipt_get_kind (receipt);
	_tmp20_ = _tmp19_;
	if (_tmp20_ == PROTON_PLUS_MODELS_STEAM_CHANGE_KIND_COMPATIBILITY_TOOL_REMOVED) {
		GeeArrayList* matching_tool_changes = NULL;
		GeeArrayList* _tmp21_;
		gboolean has_pending_install = FALSE;
		gboolean has_prior_removal = FALSE;
		gboolean _tmp61_ = FALSE;
		_tmp21_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		matching_tool_changes = _tmp21_;
		has_pending_install = FALSE;
		has_prior_removal = FALSE;
		{
			GeeIterator* _candidate_it = NULL;
			GeeHashMap* _tmp22_;
			GeeCollection* _tmp23_;
			GeeCollection* _tmp24_;
			GeeCollection* _tmp25_;
			GeeIterator* _tmp26_;
			GeeIterator* _tmp27_;
			_tmp22_ = self->priv->pending;
			_tmp23_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp22_);
			_tmp24_ = _tmp23_;
			_tmp25_ = _tmp24_;
			_tmp26_ = gee_iterable_iterator ((GeeIterable*) _tmp25_);
			_tmp27_ = _tmp26_;
			_g_object_unref0 (_tmp25_);
			_candidate_it = _tmp27_;
			while (TRUE) {
				GeeIterator* _tmp28_;
				ProtonPlusModelsSteamRestartPendingRecord* candidate = NULL;
				GeeIterator* _tmp29_;
				gpointer _tmp30_;
				gboolean _tmp31_ = FALSE;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp32_;
				ProtonPlusModelsSteamChangeReceipt* _tmp33_;
				ProtonPlusModelsSteamChangeReceipt* _tmp34_;
				ProtonPlusModelsSteamRestartTarget* _tmp35_;
				ProtonPlusModelsSteamRestartTarget* _tmp36_;
				const gchar* _tmp37_;
				const gchar* _tmp38_;
				ProtonPlusModelsSteamRestartTarget* _tmp39_;
				ProtonPlusModelsSteamRestartTarget* _tmp40_;
				const gchar* _tmp41_;
				const gchar* _tmp42_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp50_;
				ProtonPlusModelsSteamChangeReceipt* _tmp51_;
				ProtonPlusModelsSteamChangeReceipt* _tmp52_;
				ProtonPlusModelsSteamChangeKind _tmp53_;
				ProtonPlusModelsSteamChangeKind _tmp54_;
				_tmp28_ = _candidate_it;
				if (!gee_iterator_next (_tmp28_)) {
					break;
				}
				_tmp29_ = _candidate_it;
				_tmp30_ = gee_iterator_get (_tmp29_);
				candidate = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp30_;
				_tmp32_ = candidate;
				_tmp33_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp32_);
				_tmp34_ = _tmp33_;
				_tmp35_ = proton_plus_models_steam_change_receipt_get_target (_tmp34_);
				_tmp36_ = _tmp35_;
				_tmp37_ = proton_plus_models_steam_restart_target_get_id (_tmp36_);
				_tmp38_ = _tmp37_;
				_tmp39_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp40_ = _tmp39_;
				_tmp41_ = proton_plus_models_steam_restart_target_get_id (_tmp40_);
				_tmp42_ = _tmp41_;
				if (g_strcmp0 (_tmp38_, _tmp42_) != 0) {
					_tmp31_ = TRUE;
				} else {
					ProtonPlusModelsSteamRestartPendingRecord* _tmp43_;
					ProtonPlusModelsSteamChangeReceipt* _tmp44_;
					ProtonPlusModelsSteamChangeReceipt* _tmp45_;
					const gchar* _tmp46_;
					const gchar* _tmp47_;
					const gchar* _tmp48_;
					const gchar* _tmp49_;
					_tmp43_ = candidate;
					_tmp44_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp43_);
					_tmp45_ = _tmp44_;
					_tmp46_ = proton_plus_models_steam_change_receipt_get_resource_key (_tmp45_);
					_tmp47_ = _tmp46_;
					_tmp48_ = proton_plus_models_steam_change_receipt_get_resource_key (receipt);
					_tmp49_ = _tmp48_;
					_tmp31_ = g_strcmp0 (_tmp47_, _tmp49_) != 0;
				}
				if (_tmp31_) {
					_g_object_unref0 (candidate);
					continue;
				}
				_tmp50_ = candidate;
				_tmp51_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp50_);
				_tmp52_ = _tmp51_;
				_tmp53_ = proton_plus_models_steam_change_receipt_get_kind (_tmp52_);
				_tmp54_ = _tmp53_;
				switch (_tmp54_) {
					case PROTON_PLUS_MODELS_STEAM_CHANGE_KIND_COMPATIBILITY_TOOL_INSTALLED:
					{
						GeeArrayList* _tmp55_;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp56_;
						has_pending_install = TRUE;
						_tmp55_ = matching_tool_changes;
						_tmp56_ = candidate;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp55_, _tmp56_);
						break;
					}
					case PROTON_PLUS_MODELS_STEAM_CHANGE_KIND_COMPATIBILITY_TOOL_UPDATED_OR_REPLACED:
					{
						GeeArrayList* _tmp57_;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp58_;
						_tmp57_ = matching_tool_changes;
						_tmp58_ = candidate;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp57_, _tmp58_);
						break;
					}
					case PROTON_PLUS_MODELS_STEAM_CHANGE_KIND_COMPATIBILITY_TOOL_REMOVED:
					{
						GeeArrayList* _tmp59_;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp60_;
						has_prior_removal = TRUE;
						_tmp59_ = matching_tool_changes;
						_tmp60_ = candidate;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp59_, _tmp60_);
						break;
					}
					default:
					{
						break;
					}
				}
				_g_object_unref0 (candidate);
			}
			_g_object_unref0 (_candidate_it);
		}
		if (has_pending_install) {
			_tmp61_ = !has_prior_removal;
		} else {
			_tmp61_ = FALSE;
		}
		if (_tmp61_) {
			gboolean target_cleared = FALSE;
			ProtonPlusModelsSteamRestartTarget* _tmp77_;
			ProtonPlusModelsSteamRestartTarget* _tmp78_;
			{
				GeeArrayList* _removed_record_list = NULL;
				GeeArrayList* _tmp62_;
				gint _removed_record_size = 0;
				GeeArrayList* _tmp63_;
				gint _tmp64_;
				gint _tmp65_;
				gint _removed_record_index = 0;
				_tmp62_ = matching_tool_changes;
				_removed_record_list = _tmp62_;
				_tmp63_ = _removed_record_list;
				_tmp64_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp63_);
				_tmp65_ = _tmp64_;
				_removed_record_size = _tmp65_;
				_removed_record_index = -1;
				while (TRUE) {
					gint _tmp66_;
					gint _tmp67_;
					ProtonPlusModelsSteamRestartPendingRecord* removed_record = NULL;
					GeeArrayList* _tmp68_;
					gpointer _tmp69_;
					GeeHashMap* _tmp70_;
					ProtonPlusModelsSteamRestartPendingRecord* _tmp71_;
					ProtonPlusModelsSteamChangeReceipt* _tmp72_;
					ProtonPlusModelsSteamChangeReceipt* _tmp73_;
					gchar* _tmp74_;
					gchar* _tmp75_;
					gchar* _tmp76_;
					_removed_record_index = _removed_record_index + 1;
					_tmp66_ = _removed_record_index;
					_tmp67_ = _removed_record_size;
					if (!(_tmp66_ < _tmp67_)) {
						break;
					}
					_tmp68_ = _removed_record_list;
					_tmp69_ = gee_abstract_list_get ((GeeAbstractList*) _tmp68_, _removed_record_index);
					removed_record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp69_;
					_tmp70_ = self->priv->pending;
					_tmp71_ = removed_record;
					_tmp72_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp71_);
					_tmp73_ = _tmp72_;
					_tmp74_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp73_);
					_tmp75_ = _tmp74_;
					_tmp76_ = _tmp75_;
					gee_abstract_map_unset ((GeeAbstractMap*) _tmp70_, _tmp76_, NULL);
					_g_free0 (_tmp76_);
					_g_object_unref0 (removed_record);
				}
			}
			_tmp77_ = proton_plus_models_steam_change_receipt_get_target (receipt);
			_tmp78_ = _tmp77_;
			target_cleared = proton_plus_services_steam_restart_manager_pending_count_for_target (self, _tmp78_) == 0;
			if (target_cleared) {
				GeeHashMap* _tmp79_;
				ProtonPlusModelsSteamRestartTarget* _tmp80_;
				ProtonPlusModelsSteamRestartTarget* _tmp81_;
				const gchar* _tmp82_;
				const gchar* _tmp83_;
				_tmp79_ = self->priv->targets;
				_tmp80_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp81_ = _tmp80_;
				_tmp82_ = proton_plus_models_steam_restart_target_get_id (_tmp81_);
				_tmp83_ = _tmp82_;
				gee_abstract_map_unset ((GeeAbstractMap*) _tmp79_, _tmp83_, NULL);
			}
			if (!proton_plus_services_steam_restart_manager_persist (self)) {
				GeeHashMap* _tmp100_;
				ProtonPlusModelsSteamRestartTarget* _tmp101_;
				ProtonPlusModelsSteamRestartTarget* _tmp102_;
				const gchar* _tmp103_;
				const gchar* _tmp104_;
				ProtonPlusModelsSteamRestartTarget* _tmp105_;
				ProtonPlusModelsSteamRestartTarget* _tmp106_;
				{
					GeeArrayList* _removed_record_list = NULL;
					GeeArrayList* _tmp84_;
					gint _removed_record_size = 0;
					GeeArrayList* _tmp85_;
					gint _tmp86_;
					gint _tmp87_;
					gint _removed_record_index = 0;
					_tmp84_ = matching_tool_changes;
					_removed_record_list = _tmp84_;
					_tmp85_ = _removed_record_list;
					_tmp86_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp85_);
					_tmp87_ = _tmp86_;
					_removed_record_size = _tmp87_;
					_removed_record_index = -1;
					while (TRUE) {
						gint _tmp88_;
						gint _tmp89_;
						ProtonPlusModelsSteamRestartPendingRecord* removed_record = NULL;
						GeeArrayList* _tmp90_;
						gpointer _tmp91_;
						GeeHashMap* _tmp92_;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp93_;
						ProtonPlusModelsSteamChangeReceipt* _tmp94_;
						ProtonPlusModelsSteamChangeReceipt* _tmp95_;
						gchar* _tmp96_;
						gchar* _tmp97_;
						gchar* _tmp98_;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp99_;
						_removed_record_index = _removed_record_index + 1;
						_tmp88_ = _removed_record_index;
						_tmp89_ = _removed_record_size;
						if (!(_tmp88_ < _tmp89_)) {
							break;
						}
						_tmp90_ = _removed_record_list;
						_tmp91_ = gee_abstract_list_get ((GeeAbstractList*) _tmp90_, _removed_record_index);
						removed_record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp91_;
						_tmp92_ = self->priv->pending;
						_tmp93_ = removed_record;
						_tmp94_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp93_);
						_tmp95_ = _tmp94_;
						_tmp96_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp95_);
						_tmp97_ = _tmp96_;
						_tmp98_ = _tmp97_;
						_tmp99_ = removed_record;
						gee_abstract_map_set ((GeeAbstractMap*) _tmp92_, _tmp98_, _tmp99_);
						_g_free0 (_tmp98_);
						_g_object_unref0 (removed_record);
					}
				}
				_tmp100_ = self->priv->targets;
				_tmp101_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp102_ = _tmp101_;
				_tmp103_ = proton_plus_models_steam_restart_target_get_id (_tmp102_);
				_tmp104_ = _tmp103_;
				_tmp105_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp106_ = _tmp105_;
				gee_abstract_map_set ((GeeAbstractMap*) _tmp100_, _tmp104_, _tmp106_);
				result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_PERSISTENCE_FAILED;
				_g_object_unref0 (matching_tool_changes);
				_g_object_unref0 (stable_session);
				_g_object_unref0 (existing);
				_g_free0 (key);
				_g_object_unref0 (snapshot);
				return result;
			}
			g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL], 0);
			if (target_cleared) {
				ProtonPlusModelsSteamRestartTarget* _tmp107_;
				ProtonPlusModelsSteamRestartTarget* _tmp108_;
				_tmp107_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp108_ = _tmp107_;
				g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_REQUIREMENT_SATISFIED_SIGNAL], 0, _tmp108_);
			}
			result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_REQUIREMENT_CLEARED;
			_g_object_unref0 (matching_tool_changes);
			_g_object_unref0 (stable_session);
			_g_object_unref0 (existing);
			_g_free0 (key);
			_g_object_unref0 (snapshot);
			return result;
		}
		_g_object_unref0 (matching_tool_changes);
	}
	_tmp111_ = existing;
	if (_tmp111_ != NULL) {
		ProtonPlusModelsSteamConfigurationIntent* _tmp112_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp113_;
		_tmp112_ = proton_plus_models_steam_change_receipt_get_configuration_intent (receipt);
		_tmp113_ = _tmp112_;
		_tmp110_ = _tmp113_ != NULL;
	} else {
		_tmp110_ = FALSE;
	}
	if (_tmp110_) {
		ProtonPlusModelsSteamRestartPendingRecord* _tmp114_;
		ProtonPlusModelsSteamChangeReceipt* _tmp115_;
		ProtonPlusModelsSteamChangeReceipt* _tmp116_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp117_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp118_;
		_tmp114_ = existing;
		_tmp115_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp114_);
		_tmp116_ = _tmp115_;
		_tmp117_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp116_);
		_tmp118_ = _tmp117_;
		_tmp109_ = _tmp118_ != NULL;
	} else {
		_tmp109_ = FALSE;
	}
	if (_tmp109_) {
		ProtonPlusModelsSteamConfigurationIntent* old_intent = NULL;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp119_;
		ProtonPlusModelsSteamChangeReceipt* _tmp120_;
		ProtonPlusModelsSteamChangeReceipt* _tmp121_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp122_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp123_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp124_;
		ProtonPlusModelsSteamConfigurationIntent* new_intent = NULL;
		ProtonPlusModelsSteamConfigurationIntent* _tmp125_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp126_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp127_;
		gboolean _tmp128_ = FALSE;
		ProtonPlusModelsSteamConfigurationIntent* _tmp129_;
		gboolean _tmp130_;
		gboolean _tmp131_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp132_;
		gboolean _tmp133_;
		gboolean _tmp134_;
		gchar* baseline = NULL;
		ProtonPlusModelsSteamConfigurationIntent* _tmp141_;
		const gchar* _tmp142_;
		const gchar* _tmp143_;
		gchar* _tmp144_;
		gboolean _tmp145_ = FALSE;
		const gchar* _tmp146_;
		ProtonPlusModelsSteamConfigurationIntent* merged = NULL;
		ProtonPlusModelsSteamConfigurationIntent* _tmp162_;
		ProtonPlusModelsSteamConfigurationFile _tmp163_;
		ProtonPlusModelsSteamConfigurationFile _tmp164_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp165_;
		ProtonPlusModelsSteamConfigurationOperation _tmp166_;
		ProtonPlusModelsSteamConfigurationOperation _tmp167_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp168_;
		const gchar* _tmp169_;
		const gchar* _tmp170_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp171_;
		const gchar* _tmp172_;
		const gchar* _tmp173_;
		const gchar* _tmp174_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp175_;
		const gchar* _tmp176_;
		const gchar* _tmp177_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp178_;
		gboolean _tmp179_;
		gboolean _tmp180_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp181_;
		gboolean _tmp182_;
		gboolean _tmp183_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp184_;
		const gchar* _tmp185_;
		const gchar* _tmp186_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp187_;
		gboolean _tmp188_ = FALSE;
		ProtonPlusModelsSteamConfigurationIntent* _tmp189_;
		gboolean _tmp190_;
		gboolean _tmp191_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp192_;
		gboolean _tmp193_;
		gboolean _tmp194_;
		ProtonPlusModelsSteamChangeReceipt* merged_receipt = NULL;
		ProtonPlusModelsSteamRestartTarget* _tmp291_;
		ProtonPlusModelsSteamRestartTarget* _tmp292_;
		ProtonPlusModelsSteamChangeKind _tmp293_;
		ProtonPlusModelsSteamChangeKind _tmp294_;
		ProtonPlusModelsSteamRestartRequirement _tmp295_;
		ProtonPlusModelsSteamRestartRequirement _tmp296_;
		const gchar* _tmp297_;
		const gchar* _tmp298_;
		const gchar* _tmp299_;
		const gchar* _tmp300_;
		const gchar* _tmp301_;
		const gchar* _tmp302_;
		const gchar* _tmp303_;
		const gchar* _tmp304_;
		ProtonPlusModelsSteamConfigurationIntent* _tmp305_;
		ProtonPlusModelsSteamChangeReceipt* _tmp306_;
		ProtonPlusModelsSteamRestartPendingRecord* replacement = NULL;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp307_;
		ProtonPlusModelsSteamChangeReceipt* _tmp308_;
		ProtonPlusModelsSteamSessionIdentity* _tmp309_;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp310_;
		GeeHashMap* _tmp311_;
		const gchar* _tmp312_;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp313_;
		_tmp119_ = existing;
		_tmp120_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp119_);
		_tmp121_ = _tmp120_;
		_tmp122_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp121_);
		_tmp123_ = _tmp122_;
		_tmp124_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp123_, PROTON_PLUS_MODELS_TYPE_STEAM_CONFIGURATION_INTENT, ProtonPlusModelsSteamConfigurationIntent));
		old_intent = _tmp124_;
		_tmp125_ = proton_plus_models_steam_change_receipt_get_configuration_intent (receipt);
		_tmp126_ = _tmp125_;
		_tmp127_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp126_, PROTON_PLUS_MODELS_TYPE_STEAM_CONFIGURATION_INTENT, ProtonPlusModelsSteamConfigurationIntent));
		new_intent = _tmp127_;
		_tmp129_ = old_intent;
		_tmp130_ = proton_plus_models_steam_configuration_intent_get_desired_present (_tmp129_);
		_tmp131_ = _tmp130_;
		_tmp132_ = new_intent;
		_tmp133_ = proton_plus_models_steam_configuration_intent_get_desired_present (_tmp132_);
		_tmp134_ = _tmp133_;
		if (_tmp131_ == _tmp134_) {
			ProtonPlusModelsSteamConfigurationIntent* _tmp135_;
			const gchar* _tmp136_;
			const gchar* _tmp137_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp138_;
			const gchar* _tmp139_;
			const gchar* _tmp140_;
			_tmp135_ = old_intent;
			_tmp136_ = proton_plus_models_steam_configuration_intent_get_desired (_tmp135_);
			_tmp137_ = _tmp136_;
			_tmp138_ = new_intent;
			_tmp139_ = proton_plus_models_steam_configuration_intent_get_desired (_tmp138_);
			_tmp140_ = _tmp139_;
			_tmp128_ = g_strcmp0 (_tmp137_, _tmp140_) == 0;
		} else {
			_tmp128_ = FALSE;
		}
		if (_tmp128_) {
			result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_UNCHANGED;
			_g_object_unref0 (new_intent);
			_g_object_unref0 (old_intent);
			_g_object_unref0 (stable_session);
			_g_object_unref0 (existing);
			_g_free0 (key);
			_g_object_unref0 (snapshot);
			return result;
		}
		_tmp141_ = old_intent;
		_tmp142_ = proton_plus_models_steam_configuration_intent_get_baseline (_tmp141_);
		_tmp143_ = _tmp142_;
		_tmp144_ = g_strdup (_tmp143_);
		baseline = _tmp144_;
		_tmp146_ = baseline;
		if (g_strcmp0 (_tmp146_, "") == 0) {
			ProtonPlusModelsSteamConfigurationIntent* _tmp147_;
			const gchar* _tmp148_;
			const gchar* _tmp149_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp150_;
			const gchar* _tmp151_;
			const gchar* _tmp152_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp153_;
			gboolean _tmp154_;
			gboolean _tmp155_;
			gchar* _tmp156_;
			gchar* _tmp157_;
			_tmp147_ = old_intent;
			_tmp148_ = proton_plus_models_steam_configuration_intent_get_baseline_fingerprint (_tmp147_);
			_tmp149_ = _tmp148_;
			_tmp150_ = new_intent;
			_tmp151_ = proton_plus_models_steam_configuration_intent_get_baseline (_tmp150_);
			_tmp152_ = _tmp151_;
			_tmp153_ = new_intent;
			_tmp154_ = proton_plus_models_steam_configuration_intent_get_baseline_present (_tmp153_);
			_tmp155_ = _tmp154_;
			_tmp156_ = proton_plus_models_steam_configuration_intent_fingerprint (_tmp152_, _tmp155_);
			_tmp157_ = _tmp156_;
			_tmp145_ = g_strcmp0 (_tmp149_, _tmp157_) == 0;
			_g_free0 (_tmp157_);
		} else {
			_tmp145_ = FALSE;
		}
		if (_tmp145_) {
			ProtonPlusModelsSteamConfigurationIntent* _tmp158_;
			const gchar* _tmp159_;
			const gchar* _tmp160_;
			gchar* _tmp161_;
			_tmp158_ = new_intent;
			_tmp159_ = proton_plus_models_steam_configuration_intent_get_baseline (_tmp158_);
			_tmp160_ = _tmp159_;
			_tmp161_ = g_strdup (_tmp160_);
			_g_free0 (baseline);
			baseline = _tmp161_;
		}
		_tmp162_ = new_intent;
		_tmp163_ = proton_plus_models_steam_configuration_intent_get_file (_tmp162_);
		_tmp164_ = _tmp163_;
		_tmp165_ = new_intent;
		_tmp166_ = proton_plus_models_steam_configuration_intent_get_operation (_tmp165_);
		_tmp167_ = _tmp166_;
		_tmp168_ = new_intent;
		_tmp169_ = proton_plus_models_steam_configuration_intent_get_path (_tmp168_);
		_tmp170_ = _tmp169_;
		_tmp171_ = new_intent;
		_tmp172_ = proton_plus_models_steam_configuration_intent_get_field_id (_tmp171_);
		_tmp173_ = _tmp172_;
		_tmp174_ = baseline;
		_tmp175_ = new_intent;
		_tmp176_ = proton_plus_models_steam_configuration_intent_get_desired (_tmp175_);
		_tmp177_ = _tmp176_;
		_tmp178_ = old_intent;
		_tmp179_ = proton_plus_models_steam_configuration_intent_get_baseline_present (_tmp178_);
		_tmp180_ = _tmp179_;
		_tmp181_ = new_intent;
		_tmp182_ = proton_plus_models_steam_configuration_intent_get_desired_present (_tmp181_);
		_tmp183_ = _tmp182_;
		_tmp184_ = old_intent;
		_tmp185_ = proton_plus_models_steam_configuration_intent_get_baseline_fingerprint (_tmp184_);
		_tmp186_ = _tmp185_;
		_tmp187_ = proton_plus_models_steam_configuration_intent_new (_tmp164_, _tmp167_, _tmp170_, _tmp173_, _tmp174_, _tmp177_, _tmp180_, _tmp183_, _tmp186_);
		merged = _tmp187_;
		_tmp189_ = merged;
		_tmp190_ = proton_plus_models_steam_configuration_intent_get_desired_present (_tmp189_);
		_tmp191_ = _tmp190_;
		_tmp192_ = merged;
		_tmp193_ = proton_plus_models_steam_configuration_intent_get_baseline_present (_tmp192_);
		_tmp194_ = _tmp193_;
		if (_tmp191_ == _tmp194_) {
			ProtonPlusModelsSteamConfigurationIntent* _tmp195_;
			const gchar* _tmp196_;
			const gchar* _tmp197_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp198_;
			const gchar* _tmp199_;
			const gchar* _tmp200_;
			_tmp195_ = merged;
			_tmp196_ = proton_plus_models_steam_configuration_intent_get_desired (_tmp195_);
			_tmp197_ = _tmp196_;
			_tmp198_ = merged;
			_tmp199_ = proton_plus_models_steam_configuration_intent_get_baseline (_tmp198_);
			_tmp200_ = _tmp199_;
			_tmp188_ = g_strcmp0 (_tmp197_, _tmp200_) == 0;
		} else {
			_tmp188_ = FALSE;
		}
		if (_tmp188_) {
			GeeArrayList* removed = NULL;
			GeeArrayList* _tmp201_;
			GeeArrayList* _tmp202_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp203_;
			gboolean _tmp204_ = FALSE;
			gboolean _tmp205_ = FALSE;
			ProtonPlusModelsSteamConfigurationIntent* _tmp206_;
			ProtonPlusModelsSteamConfigurationOperation _tmp207_;
			ProtonPlusModelsSteamConfigurationOperation _tmp208_;
			gboolean target_cleared = FALSE;
			ProtonPlusModelsSteamRestartTarget* _tmp259_;
			ProtonPlusModelsSteamRestartTarget* _tmp260_;
			_tmp201_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
			removed = _tmp201_;
			_tmp202_ = removed;
			_tmp203_ = existing;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp202_, _tmp203_);
			_tmp206_ = merged;
			_tmp207_ = proton_plus_models_steam_configuration_intent_get_operation (_tmp206_);
			_tmp208_ = _tmp207_;
			if (_tmp208_ == PROTON_PLUS_MODELS_STEAM_CONFIGURATION_OPERATION_SHORTCUT_PRESENCE) {
				ProtonPlusModelsSteamConfigurationIntent* _tmp209_;
				gboolean _tmp210_;
				gboolean _tmp211_;
				_tmp209_ = merged;
				_tmp210_ = proton_plus_models_steam_configuration_intent_get_baseline_present (_tmp209_);
				_tmp211_ = _tmp210_;
				_tmp205_ = !_tmp211_;
			} else {
				_tmp205_ = FALSE;
			}
			if (_tmp205_) {
				ProtonPlusModelsSteamConfigurationIntent* _tmp212_;
				gboolean _tmp213_;
				gboolean _tmp214_;
				_tmp212_ = merged;
				_tmp213_ = proton_plus_models_steam_configuration_intent_get_desired_present (_tmp212_);
				_tmp214_ = _tmp213_;
				_tmp204_ = !_tmp214_;
			} else {
				_tmp204_ = FALSE;
			}
			if (_tmp204_) {
				{
					GeeIterator* _candidate_it = NULL;
					GeeHashMap* _tmp215_;
					GeeCollection* _tmp216_;
					GeeCollection* _tmp217_;
					GeeCollection* _tmp218_;
					GeeIterator* _tmp219_;
					GeeIterator* _tmp220_;
					_tmp215_ = self->priv->pending;
					_tmp216_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp215_);
					_tmp217_ = _tmp216_;
					_tmp218_ = _tmp217_;
					_tmp219_ = gee_iterable_iterator ((GeeIterable*) _tmp218_);
					_tmp220_ = _tmp219_;
					_g_object_unref0 (_tmp218_);
					_candidate_it = _tmp220_;
					while (TRUE) {
						GeeIterator* _tmp221_;
						ProtonPlusModelsSteamRestartPendingRecord* candidate = NULL;
						GeeIterator* _tmp222_;
						gpointer _tmp223_;
						ProtonPlusModelsSteamConfigurationIntent* candidate_intent = NULL;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp224_;
						ProtonPlusModelsSteamChangeReceipt* _tmp225_;
						ProtonPlusModelsSteamChangeReceipt* _tmp226_;
						ProtonPlusModelsSteamConfigurationIntent* _tmp227_;
						ProtonPlusModelsSteamConfigurationIntent* _tmp228_;
						ProtonPlusModelsSteamConfigurationIntent* _tmp229_;
						gboolean _tmp230_ = FALSE;
						gboolean _tmp231_ = FALSE;
						ProtonPlusModelsSteamConfigurationIntent* _tmp232_;
						_tmp221_ = _candidate_it;
						if (!gee_iterator_next (_tmp221_)) {
							break;
						}
						_tmp222_ = _candidate_it;
						_tmp223_ = gee_iterator_get (_tmp222_);
						candidate = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp223_;
						_tmp224_ = candidate;
						_tmp225_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp224_);
						_tmp226_ = _tmp225_;
						_tmp227_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp226_);
						_tmp228_ = _tmp227_;
						_tmp229_ = _g_object_ref0 (_tmp228_);
						candidate_intent = _tmp229_;
						_tmp232_ = candidate_intent;
						if (_tmp232_ != NULL) {
							ProtonPlusModelsSteamConfigurationIntent* _tmp233_;
							ProtonPlusModelsSteamConfigurationOperation _tmp234_;
							ProtonPlusModelsSteamConfigurationOperation _tmp235_;
							_tmp233_ = candidate_intent;
							_tmp234_ = proton_plus_models_steam_configuration_intent_get_operation (G_TYPE_CHECK_INSTANCE_CAST (_tmp233_, PROTON_PLUS_MODELS_TYPE_STEAM_CONFIGURATION_INTENT, ProtonPlusModelsSteamConfigurationIntent));
							_tmp235_ = _tmp234_;
							_tmp231_ = _tmp235_ == PROTON_PLUS_MODELS_STEAM_CONFIGURATION_OPERATION_SHORTCUTS_FILE_PRESENT;
						} else {
							_tmp231_ = FALSE;
						}
						if (_tmp231_) {
							ProtonPlusModelsSteamConfigurationIntent* _tmp236_;
							const gchar* _tmp237_;
							const gchar* _tmp238_;
							ProtonPlusModelsSteamConfigurationIntent* _tmp239_;
							const gchar* _tmp240_;
							const gchar* _tmp241_;
							_tmp236_ = candidate_intent;
							_tmp237_ = proton_plus_models_steam_configuration_intent_get_path (G_TYPE_CHECK_INSTANCE_CAST (_tmp236_, PROTON_PLUS_MODELS_TYPE_STEAM_CONFIGURATION_INTENT, ProtonPlusModelsSteamConfigurationIntent));
							_tmp238_ = _tmp237_;
							_tmp239_ = merged;
							_tmp240_ = proton_plus_models_steam_configuration_intent_get_path (_tmp239_);
							_tmp241_ = _tmp240_;
							_tmp230_ = g_strcmp0 (_tmp238_, _tmp241_) == 0;
						} else {
							_tmp230_ = FALSE;
						}
						if (_tmp230_) {
							GeeArrayList* _tmp242_;
							ProtonPlusModelsSteamRestartPendingRecord* _tmp243_;
							_tmp242_ = removed;
							_tmp243_ = candidate;
							gee_abstract_collection_add ((GeeAbstractCollection*) _tmp242_, _tmp243_);
						}
						_g_object_unref0 (candidate_intent);
						_g_object_unref0 (candidate);
					}
					_g_object_unref0 (_candidate_it);
				}
			}
			{
				GeeArrayList* _removed_record_list = NULL;
				GeeArrayList* _tmp244_;
				gint _removed_record_size = 0;
				GeeArrayList* _tmp245_;
				gint _tmp246_;
				gint _tmp247_;
				gint _removed_record_index = 0;
				_tmp244_ = removed;
				_removed_record_list = _tmp244_;
				_tmp245_ = _removed_record_list;
				_tmp246_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp245_);
				_tmp247_ = _tmp246_;
				_removed_record_size = _tmp247_;
				_removed_record_index = -1;
				while (TRUE) {
					gint _tmp248_;
					gint _tmp249_;
					ProtonPlusModelsSteamRestartPendingRecord* removed_record = NULL;
					GeeArrayList* _tmp250_;
					gpointer _tmp251_;
					GeeHashMap* _tmp252_;
					ProtonPlusModelsSteamRestartPendingRecord* _tmp253_;
					ProtonPlusModelsSteamChangeReceipt* _tmp254_;
					ProtonPlusModelsSteamChangeReceipt* _tmp255_;
					gchar* _tmp256_;
					gchar* _tmp257_;
					gchar* _tmp258_;
					_removed_record_index = _removed_record_index + 1;
					_tmp248_ = _removed_record_index;
					_tmp249_ = _removed_record_size;
					if (!(_tmp248_ < _tmp249_)) {
						break;
					}
					_tmp250_ = _removed_record_list;
					_tmp251_ = gee_abstract_list_get ((GeeAbstractList*) _tmp250_, _removed_record_index);
					removed_record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp251_;
					_tmp252_ = self->priv->pending;
					_tmp253_ = removed_record;
					_tmp254_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp253_);
					_tmp255_ = _tmp254_;
					_tmp256_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp255_);
					_tmp257_ = _tmp256_;
					_tmp258_ = _tmp257_;
					gee_abstract_map_unset ((GeeAbstractMap*) _tmp252_, _tmp258_, NULL);
					_g_free0 (_tmp258_);
					_g_object_unref0 (removed_record);
				}
			}
			_tmp259_ = proton_plus_models_steam_change_receipt_get_target (receipt);
			_tmp260_ = _tmp259_;
			target_cleared = proton_plus_services_steam_restart_manager_pending_count_for_target (self, _tmp260_) == 0;
			if (target_cleared) {
				GeeHashMap* _tmp261_;
				ProtonPlusModelsSteamRestartTarget* _tmp262_;
				ProtonPlusModelsSteamRestartTarget* _tmp263_;
				const gchar* _tmp264_;
				const gchar* _tmp265_;
				_tmp261_ = self->priv->targets;
				_tmp262_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp263_ = _tmp262_;
				_tmp264_ = proton_plus_models_steam_restart_target_get_id (_tmp263_);
				_tmp265_ = _tmp264_;
				gee_abstract_map_unset ((GeeAbstractMap*) _tmp261_, _tmp265_, NULL);
			}
			if (!proton_plus_services_steam_restart_manager_persist (self)) {
				GeeHashMap* _tmp282_;
				ProtonPlusModelsSteamRestartTarget* _tmp283_;
				ProtonPlusModelsSteamRestartTarget* _tmp284_;
				const gchar* _tmp285_;
				const gchar* _tmp286_;
				ProtonPlusModelsSteamRestartTarget* _tmp287_;
				ProtonPlusModelsSteamRestartTarget* _tmp288_;
				{
					GeeArrayList* _removed_record_list = NULL;
					GeeArrayList* _tmp266_;
					gint _removed_record_size = 0;
					GeeArrayList* _tmp267_;
					gint _tmp268_;
					gint _tmp269_;
					gint _removed_record_index = 0;
					_tmp266_ = removed;
					_removed_record_list = _tmp266_;
					_tmp267_ = _removed_record_list;
					_tmp268_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp267_);
					_tmp269_ = _tmp268_;
					_removed_record_size = _tmp269_;
					_removed_record_index = -1;
					while (TRUE) {
						gint _tmp270_;
						gint _tmp271_;
						ProtonPlusModelsSteamRestartPendingRecord* removed_record = NULL;
						GeeArrayList* _tmp272_;
						gpointer _tmp273_;
						GeeHashMap* _tmp274_;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp275_;
						ProtonPlusModelsSteamChangeReceipt* _tmp276_;
						ProtonPlusModelsSteamChangeReceipt* _tmp277_;
						gchar* _tmp278_;
						gchar* _tmp279_;
						gchar* _tmp280_;
						ProtonPlusModelsSteamRestartPendingRecord* _tmp281_;
						_removed_record_index = _removed_record_index + 1;
						_tmp270_ = _removed_record_index;
						_tmp271_ = _removed_record_size;
						if (!(_tmp270_ < _tmp271_)) {
							break;
						}
						_tmp272_ = _removed_record_list;
						_tmp273_ = gee_abstract_list_get ((GeeAbstractList*) _tmp272_, _removed_record_index);
						removed_record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp273_;
						_tmp274_ = self->priv->pending;
						_tmp275_ = removed_record;
						_tmp276_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp275_);
						_tmp277_ = _tmp276_;
						_tmp278_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp277_);
						_tmp279_ = _tmp278_;
						_tmp280_ = _tmp279_;
						_tmp281_ = removed_record;
						gee_abstract_map_set ((GeeAbstractMap*) _tmp274_, _tmp280_, _tmp281_);
						_g_free0 (_tmp280_);
						_g_object_unref0 (removed_record);
					}
				}
				_tmp282_ = self->priv->targets;
				_tmp283_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp284_ = _tmp283_;
				_tmp285_ = proton_plus_models_steam_restart_target_get_id (_tmp284_);
				_tmp286_ = _tmp285_;
				_tmp287_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp288_ = _tmp287_;
				gee_abstract_map_set ((GeeAbstractMap*) _tmp282_, _tmp286_, _tmp288_);
				result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_PERSISTENCE_FAILED;
				_g_object_unref0 (removed);
				_g_object_unref0 (merged);
				_g_free0 (baseline);
				_g_object_unref0 (new_intent);
				_g_object_unref0 (old_intent);
				_g_object_unref0 (stable_session);
				_g_object_unref0 (existing);
				_g_free0 (key);
				_g_object_unref0 (snapshot);
				return result;
			}
			g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL], 0);
			if (target_cleared) {
				ProtonPlusModelsSteamRestartTarget* _tmp289_;
				ProtonPlusModelsSteamRestartTarget* _tmp290_;
				_tmp289_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp290_ = _tmp289_;
				g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_REQUIREMENT_SATISFIED_SIGNAL], 0, _tmp290_);
			}
			result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_REQUIREMENT_CLEARED;
			_g_object_unref0 (removed);
			_g_object_unref0 (merged);
			_g_free0 (baseline);
			_g_object_unref0 (new_intent);
			_g_object_unref0 (old_intent);
			_g_object_unref0 (stable_session);
			_g_object_unref0 (existing);
			_g_free0 (key);
			_g_object_unref0 (snapshot);
			return result;
		}
		_tmp291_ = proton_plus_models_steam_change_receipt_get_target (receipt);
		_tmp292_ = _tmp291_;
		_tmp293_ = proton_plus_models_steam_change_receipt_get_kind (receipt);
		_tmp294_ = _tmp293_;
		_tmp295_ = proton_plus_models_steam_change_receipt_get_restart_requirement (receipt);
		_tmp296_ = _tmp295_;
		_tmp297_ = proton_plus_models_steam_change_receipt_get_resource_key (receipt);
		_tmp298_ = _tmp297_;
		_tmp299_ = proton_plus_models_steam_change_receipt_get_subject_id (receipt);
		_tmp300_ = _tmp299_;
		_tmp301_ = proton_plus_models_steam_change_receipt_get_subject_label (receipt);
		_tmp302_ = _tmp301_;
		_tmp303_ = proton_plus_models_steam_change_receipt_get_changed_at (receipt);
		_tmp304_ = _tmp303_;
		_tmp305_ = merged;
		_tmp306_ = proton_plus_models_steam_change_receipt_new (_tmp292_, _tmp294_, _tmp296_, _tmp298_, _tmp300_, _tmp302_, _tmp304_, _tmp305_);
		merged_receipt = _tmp306_;
		_tmp307_ = existing;
		_tmp308_ = merged_receipt;
		_tmp309_ = stable_session;
		_tmp310_ = proton_plus_services_steam_restart_manager_updated_record (self, _tmp307_, _tmp308_, _tmp309_);
		replacement = _tmp310_;
		_tmp311_ = self->priv->pending;
		_tmp312_ = key;
		_tmp313_ = replacement;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp311_, _tmp312_, _tmp313_);
		if (!proton_plus_services_steam_restart_manager_persist (self)) {
			GeeHashMap* _tmp314_;
			const gchar* _tmp315_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp316_;
			_tmp314_ = self->priv->pending;
			_tmp315_ = key;
			_tmp316_ = existing;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp314_, _tmp315_, _tmp316_);
			result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_PERSISTENCE_FAILED;
			_g_object_unref0 (replacement);
			_g_object_unref0 (merged_receipt);
			_g_object_unref0 (merged);
			_g_free0 (baseline);
			_g_object_unref0 (new_intent);
			_g_object_unref0 (old_intent);
			_g_object_unref0 (stable_session);
			_g_object_unref0 (existing);
			_g_free0 (key);
			_g_object_unref0 (snapshot);
			return result;
		}
		g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL], 0);
		result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_UPDATED;
		_g_object_unref0 (replacement);
		_g_object_unref0 (merged_receipt);
		_g_object_unref0 (merged);
		_g_free0 (baseline);
		_g_object_unref0 (new_intent);
		_g_object_unref0 (old_intent);
		_g_object_unref0 (stable_session);
		_g_object_unref0 (existing);
		_g_free0 (key);
		_g_object_unref0 (snapshot);
		return result;
	}
	_tmp317_ = existing;
	if (_tmp317_ == NULL) {
		GeeHashMap* _tmp318_;
		const gchar* _tmp319_;
		const gchar* _tmp320_;
		const gchar* _tmp321_;
		const gchar* _tmp322_;
		const gchar* _tmp323_;
		ProtonPlusModelsSteamSessionIdentity* _tmp324_;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp325_;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp326_;
		GeeHashMap* _tmp327_;
		ProtonPlusModelsSteamRestartTarget* _tmp328_;
		ProtonPlusModelsSteamRestartTarget* _tmp329_;
		const gchar* _tmp330_;
		const gchar* _tmp331_;
		ProtonPlusModelsSteamRestartTarget* _tmp332_;
		ProtonPlusModelsSteamRestartTarget* _tmp333_;
		_tmp318_ = self->priv->pending;
		_tmp319_ = key;
		_tmp320_ = proton_plus_models_steam_change_receipt_get_changed_at (receipt);
		_tmp321_ = _tmp320_;
		_tmp322_ = proton_plus_models_steam_change_receipt_get_changed_at (receipt);
		_tmp323_ = _tmp322_;
		_tmp324_ = stable_session;
		_tmp325_ = proton_plus_models_steam_restart_pending_record_new (receipt, _tmp321_, _tmp323_, (guint) 1, _tmp324_, FALSE);
		_tmp326_ = _tmp325_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp318_, _tmp319_, _tmp326_);
		_g_object_unref0 (_tmp326_);
		_tmp327_ = self->priv->targets;
		_tmp328_ = proton_plus_models_steam_change_receipt_get_target (receipt);
		_tmp329_ = _tmp328_;
		_tmp330_ = proton_plus_models_steam_restart_target_get_id (_tmp329_);
		_tmp331_ = _tmp330_;
		_tmp332_ = proton_plus_models_steam_change_receipt_get_target (receipt);
		_tmp333_ = _tmp332_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp327_, _tmp331_, _tmp333_);
	} else {
		GeeHashMap* _tmp334_;
		const gchar* _tmp335_;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp336_;
		ProtonPlusModelsSteamSessionIdentity* _tmp337_;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp338_;
		ProtonPlusModelsSteamRestartPendingRecord* _tmp339_;
		_tmp334_ = self->priv->pending;
		_tmp335_ = key;
		_tmp336_ = existing;
		_tmp337_ = stable_session;
		_tmp338_ = proton_plus_services_steam_restart_manager_updated_record (self, _tmp336_, receipt, _tmp337_);
		_tmp339_ = _tmp338_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp334_, _tmp335_, _tmp339_);
		_g_object_unref0 (_tmp339_);
	}
	if (!proton_plus_services_steam_restart_manager_persist (self)) {
		ProtonPlusModelsSteamRestartPendingRecord* _tmp340_;
		_tmp340_ = existing;
		if (_tmp340_ == NULL) {
			GeeHashMap* _tmp341_;
			const gchar* _tmp342_;
			ProtonPlusModelsSteamRestartTarget* _tmp343_;
			ProtonPlusModelsSteamRestartTarget* _tmp344_;
			_tmp341_ = self->priv->pending;
			_tmp342_ = key;
			gee_abstract_map_unset ((GeeAbstractMap*) _tmp341_, _tmp342_, NULL);
			_tmp343_ = proton_plus_models_steam_change_receipt_get_target (receipt);
			_tmp344_ = _tmp343_;
			if (proton_plus_services_steam_restart_manager_pending_count_for_target (self, _tmp344_) == 0) {
				GeeHashMap* _tmp345_;
				ProtonPlusModelsSteamRestartTarget* _tmp346_;
				ProtonPlusModelsSteamRestartTarget* _tmp347_;
				const gchar* _tmp348_;
				const gchar* _tmp349_;
				_tmp345_ = self->priv->targets;
				_tmp346_ = proton_plus_models_steam_change_receipt_get_target (receipt);
				_tmp347_ = _tmp346_;
				_tmp348_ = proton_plus_models_steam_restart_target_get_id (_tmp347_);
				_tmp349_ = _tmp348_;
				gee_abstract_map_unset ((GeeAbstractMap*) _tmp345_, _tmp349_, NULL);
			}
		} else {
			GeeHashMap* _tmp350_;
			const gchar* _tmp351_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp352_;
			_tmp350_ = self->priv->pending;
			_tmp351_ = key;
			_tmp352_ = existing;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp350_, _tmp351_, _tmp352_);
		}
		result = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_PERSISTENCE_FAILED;
		_g_object_unref0 (stable_session);
		_g_object_unref0 (existing);
		_g_free0 (key);
		_g_object_unref0 (snapshot);
		return result;
	}
	_tmp353_ = proton_plus_models_steam_change_receipt_get_target (receipt);
	_tmp354_ = _tmp353_;
	proton_plus_services_steam_restart_manager_watch_target (self, _tmp354_);
	g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL], 0);
	if (was_empty) {
		ProtonPlusModelsSteamRestartTarget* _tmp355_;
		ProtonPlusModelsSteamRestartTarget* _tmp356_;
		_tmp355_ = proton_plus_models_steam_change_receipt_get_target (receipt);
		_tmp356_ = _tmp355_;
		g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_BECAME_REQUIRED_SIGNAL], 0, _tmp356_);
	}
	_tmp358_ = existing;
	if (_tmp358_ == NULL) {
		_tmp357_ = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_ADDED;
	} else {
		_tmp357_ = PROTON_PLUS_SERVICES_STEAM_RESTART_RECORD_RESULT_UPDATED;
	}
	result = _tmp357_;
	_g_object_unref0 (stable_session);
	_g_object_unref0 (existing);
	_g_free0 (key);
	_g_object_unref0 (snapshot);
	return result;
}

static void
__lambda12_ (ProtonPlusServicesSteamRestartManager* self,
             ProtonPlusModelsSteamRestartTarget* target,
             ProtonPlusServicesSteamSessionSnapshot* snapshot)
{
	g_return_if_fail (target != NULL);
	g_return_if_fail (snapshot != NULL);
	proton_plus_services_steam_restart_manager_reconcile_snapshot (self, target, snapshot);
}

static void
___lambda12__proton_plus_services_steam_session_service_state_changed (ProtonPlusServicesSteamSessionService* _sender,
                                                                       ProtonPlusModelsSteamRestartTarget* target,
                                                                       ProtonPlusServicesSteamSessionSnapshot* snapshot,
                                                                       gpointer self)
{
	__lambda12_ ((ProtonPlusServicesSteamRestartManager*) self, target, snapshot);
}

void
proton_plus_services_steam_restart_manager_start_observation (ProtonPlusServicesSteamRestartManager* self)
{
	ProtonPlusServicesSteamSessionService* _tmp0_;
	gulong _tmp1_;
	ProtonPlusServicesSteamSessionService* _tmp13_;
	g_return_if_fail (self != NULL);
	if (self->priv->observation_started) {
		return;
	}
	_tmp0_ = self->priv->session_service;
	_tmp1_ = g_signal_connect_object (_tmp0_, "state-changed", (GCallback) ___lambda12__proton_plus_services_steam_session_service_state_changed, self, 0);
	self->priv->state_changed_handler_id = _tmp1_;
	{
		GeeList* _target_list = NULL;
		GeeList* _tmp2_;
		gint _target_size = 0;
		GeeList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _target_index = 0;
		_tmp2_ = proton_plus_services_steam_restart_manager_get_pending_targets (self);
		_target_list = _tmp2_;
		_tmp3_ = _target_list;
		_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_target_size = _tmp5_;
		_target_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			ProtonPlusModelsSteamRestartTarget* target = NULL;
			GeeList* _tmp8_;
			gpointer _tmp9_;
			ProtonPlusServicesSteamSessionService* _tmp10_;
			ProtonPlusModelsSteamRestartTarget* _tmp11_;
			ProtonPlusModelsSteamRestartTarget* _tmp12_;
			_target_index = _target_index + 1;
			_tmp6_ = _target_index;
			_tmp7_ = _target_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _target_list;
			_tmp9_ = gee_list_get (_tmp8_, _target_index);
			target = (ProtonPlusModelsSteamRestartTarget*) _tmp9_;
			_tmp10_ = self->priv->session_service;
			_tmp11_ = target;
			proton_plus_services_steam_session_service_watch_target (_tmp10_, _tmp11_);
			_tmp12_ = target;
			proton_plus_services_steam_restart_manager_reconcile_startup_target (self, _tmp12_);
			_g_object_unref0 (target);
		}
		_g_object_unref0 (_target_list);
	}
	_tmp13_ = self->priv->session_service;
	proton_plus_services_steam_session_service_start_monitoring (_tmp13_);
	self->priv->observation_started = TRUE;
}

void
proton_plus_services_steam_restart_manager_stop_observation (ProtonPlusServicesSteamRestartManager* self)
{
	ProtonPlusServicesSteamSessionService* _tmp1_;
	g_return_if_fail (self != NULL);
	if (!self->priv->observation_started) {
		return;
	}
	if (self->priv->state_changed_handler_id != ((gulong) 0)) {
		ProtonPlusServicesSteamSessionService* _tmp0_;
		_tmp0_ = self->priv->session_service;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->state_changed_handler_id);
		self->priv->state_changed_handler_id = (gulong) 0;
	}
	_tmp1_ = self->priv->session_service;
	proton_plus_services_steam_session_service_stop_monitoring (_tmp1_);
	self->priv->observation_started = FALSE;
}

void
proton_plus_services_steam_restart_manager_reconcile_target (ProtonPlusServicesSteamRestartManager* self,
                                                             ProtonPlusModelsSteamRestartTarget* target)
{
	ProtonPlusServicesSteamSessionService* _tmp0_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp1_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (target != NULL);
	_tmp0_ = self->priv->session_service;
	_tmp1_ = proton_plus_services_steam_session_service_inspect (_tmp0_, target);
	_tmp2_ = _tmp1_;
	proton_plus_services_steam_restart_manager_reconcile_snapshot (self, target, _tmp2_);
	_g_object_unref0 (_tmp2_);
}

static void
proton_plus_services_steam_restart_manager_reconcile_startup_target (ProtonPlusServicesSteamRestartManager* self,
                                                                     ProtonPlusModelsSteamRestartTarget* target)
{
	ProtonPlusServicesSteamSessionSnapshot* snapshot = NULL;
	ProtonPlusServicesSteamSessionService* _tmp0_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp1_;
	gboolean _tmp2_ = FALSE;
	ProtonPlusServicesSteamSessionSnapshot* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	ProtonPlusServicesSteamSessionSnapshot* _tmp8_;
	GeeList* records = NULL;
	GeeList* _tmp10_;
	gboolean has_configuration_intent = FALSE;
	GeeList* _tmp36_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (target != NULL);
	_tmp0_ = self->priv->session_service;
	_tmp1_ = proton_plus_services_steam_session_service_inspect (_tmp0_, target);
	snapshot = _tmp1_;
	_tmp3_ = snapshot;
	_tmp4_ = proton_plus_services_steam_session_snapshot_get_target_id (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = proton_plus_models_steam_restart_target_get_id (target);
	_tmp7_ = _tmp6_;
	if (g_strcmp0 (_tmp5_, _tmp7_) != 0) {
		_tmp2_ = TRUE;
	} else {
		_tmp2_ = proton_plus_services_steam_restart_manager_pending_count_for_target (self, target) == 0;
	}
	if (_tmp2_) {
		_g_object_unref0 (snapshot);
		return;
	}
	_tmp8_ = snapshot;
	if (!proton_plus_services_steam_restart_manager_is_confirmed_stopped (self, _tmp8_)) {
		ProtonPlusServicesSteamSessionSnapshot* _tmp9_;
		_tmp9_ = snapshot;
		proton_plus_services_steam_restart_manager_reconcile_snapshot (self, target, _tmp9_);
		_g_object_unref0 (snapshot);
		return;
	}
	_tmp10_ = proton_plus_services_steam_restart_manager_get_pending_changes_for_target (self, target);
	records = _tmp10_;
	has_configuration_intent = FALSE;
	{
		GeeList* _record_list = NULL;
		GeeList* _tmp11_;
		gint _record_size = 0;
		GeeList* _tmp12_;
		gint _tmp13_;
		gint _tmp14_;
		gint _record_index = 0;
		_tmp11_ = records;
		_record_list = _tmp11_;
		_tmp12_ = _record_list;
		_tmp13_ = gee_collection_get_size ((GeeCollection*) _tmp12_);
		_tmp14_ = _tmp13_;
		_record_size = _tmp14_;
		_record_index = -1;
		while (TRUE) {
			gint _tmp15_;
			gint _tmp16_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeList* _tmp17_;
			gpointer _tmp18_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp19_;
			ProtonPlusModelsSteamChangeReceipt* _tmp20_;
			ProtonPlusModelsSteamChangeReceipt* _tmp21_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp22_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp23_;
			_record_index = _record_index + 1;
			_tmp15_ = _record_index;
			_tmp16_ = _record_size;
			if (!(_tmp15_ < _tmp16_)) {
				break;
			}
			_tmp17_ = _record_list;
			_tmp18_ = gee_list_get (_tmp17_, _record_index);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp18_;
			_tmp19_ = record;
			_tmp20_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp21_);
			_tmp23_ = _tmp22_;
			if (_tmp23_ != NULL) {
				has_configuration_intent = TRUE;
				_g_object_unref0 (record);
				break;
			}
			_g_object_unref0 (record);
		}
	}
	if (has_configuration_intent) {
		ProtonPlusServicesSteamConfigurationReconciler* configuration = NULL;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp24_;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp25_;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp26_;
		ProtonPlusServicesSteamConfigurationMutation* outcome = NULL;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp27_;
		ProtonPlusServicesSteamConfigurationMutation* _tmp28_;
		gboolean _tmp29_ = FALSE;
		ProtonPlusServicesSteamConfigurationMutation* _tmp30_;
		ProtonPlusServicesSteamConfigurationMutationResult _tmp31_;
		ProtonPlusServicesSteamConfigurationMutationResult _tmp32_;
		_tmp24_ = self->priv->configuration_reconciler;
		_tmp25_ = _g_object_ref0 (_tmp24_);
		configuration = _tmp25_;
		_tmp26_ = configuration;
		if (_tmp26_ == NULL) {
			proton_plus_services_steam_restart_manager_mark_stop_observed (self, target);
			_g_object_unref0 (configuration);
			_g_object_unref0 (records);
			_g_object_unref0 (snapshot);
			return;
		}
		_tmp27_ = configuration;
		_tmp28_ = proton_plus_services_steam_configuration_reconciler_reconcile_target (G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, PROTON_PLUS_SERVICES_TYPE_STEAM_CONFIGURATION_RECONCILER, ProtonPlusServicesSteamConfigurationReconciler), target);
		outcome = _tmp28_;
		_tmp30_ = outcome;
		_tmp31_ = proton_plus_services_steam_configuration_mutation_get_result (_tmp30_);
		_tmp32_ = _tmp31_;
		if (_tmp32_ != PROTON_PLUS_SERVICES_STEAM_CONFIGURATION_MUTATION_RESULT_CHANGED) {
			ProtonPlusServicesSteamConfigurationMutation* _tmp33_;
			ProtonPlusServicesSteamConfigurationMutationResult _tmp34_;
			ProtonPlusServicesSteamConfigurationMutationResult _tmp35_;
			_tmp33_ = outcome;
			_tmp34_ = proton_plus_services_steam_configuration_mutation_get_result (_tmp33_);
			_tmp35_ = _tmp34_;
			_tmp29_ = _tmp35_ != PROTON_PLUS_SERVICES_STEAM_CONFIGURATION_MUTATION_RESULT_UNCHANGED;
		} else {
			_tmp29_ = FALSE;
		}
		if (_tmp29_) {
			proton_plus_services_steam_restart_manager_mark_stop_observed (self, target);
			_g_object_unref0 (outcome);
			_g_object_unref0 (configuration);
			_g_object_unref0 (records);
			_g_object_unref0 (snapshot);
			return;
		}
		_g_object_unref0 (outcome);
		_g_object_unref0 (configuration);
	}
	_tmp36_ = records;
	proton_plus_services_steam_restart_manager_clear_records (self, (GeeCollection*) _tmp36_);
	_g_object_unref0 (records);
	_g_object_unref0 (snapshot);
}

void
proton_plus_services_steam_restart_manager_reconcile_snapshot (ProtonPlusServicesSteamRestartManager* self,
                                                               ProtonPlusModelsSteamRestartTarget* target,
                                                               ProtonPlusServicesSteamSessionSnapshot* snapshot)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	ProtonPlusServicesSteamSessionState _tmp25_;
	ProtonPlusServicesSteamSessionState _tmp26_;
	ProtonPlusModelsSteamSessionIdentity* current = NULL;
	ProtonPlusModelsSteamSessionIdentity* _tmp27_;
	ProtonPlusModelsSteamSessionIdentity* _tmp28_;
	gboolean configuration_needs_verification = FALSE;
	GeeArrayList* cleared = NULL;
	GeeArrayList* _tmp60_;
	GeeArrayList* _tmp90_;
	gint _tmp91_;
	gint _tmp92_;
	gboolean target_cleared = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (target != NULL);
	g_return_if_fail (snapshot != NULL);
	_tmp1_ = proton_plus_services_steam_session_snapshot_get_target_id (snapshot);
	_tmp2_ = _tmp1_;
	_tmp3_ = proton_plus_models_steam_restart_target_get_id (target);
	_tmp4_ = _tmp3_;
	if (g_strcmp0 (_tmp2_, _tmp4_) != 0) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = proton_plus_services_steam_restart_manager_pending_count_for_target (self, target) == 0;
	}
	if (_tmp0_) {
		return;
	}
	if (proton_plus_services_steam_restart_manager_is_confirmed_stopped (self, snapshot)) {
		ProtonPlusServicesSteamConfigurationReconciler* configuration = NULL;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp5_;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp6_;
		gboolean has_configuration_intent = FALSE;
		gboolean _tmp20_ = FALSE;
		proton_plus_services_steam_restart_manager_mark_stop_observed (self, target);
		_tmp5_ = self->priv->configuration_reconciler;
		_tmp6_ = _g_object_ref0 (_tmp5_);
		configuration = _tmp6_;
		has_configuration_intent = FALSE;
		{
			GeeList* _record_list = NULL;
			GeeList* _tmp7_;
			gint _record_size = 0;
			GeeList* _tmp8_;
			gint _tmp9_;
			gint _tmp10_;
			gint _record_index = 0;
			_tmp7_ = proton_plus_services_steam_restart_manager_get_pending_changes_for_target (self, target);
			_record_list = _tmp7_;
			_tmp8_ = _record_list;
			_tmp9_ = gee_collection_get_size ((GeeCollection*) _tmp8_);
			_tmp10_ = _tmp9_;
			_record_size = _tmp10_;
			_record_index = -1;
			while (TRUE) {
				gint _tmp11_;
				gint _tmp12_;
				ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
				GeeList* _tmp13_;
				gpointer _tmp14_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp15_;
				ProtonPlusModelsSteamChangeReceipt* _tmp16_;
				ProtonPlusModelsSteamChangeReceipt* _tmp17_;
				ProtonPlusModelsSteamConfigurationIntent* _tmp18_;
				ProtonPlusModelsSteamConfigurationIntent* _tmp19_;
				_record_index = _record_index + 1;
				_tmp11_ = _record_index;
				_tmp12_ = _record_size;
				if (!(_tmp11_ < _tmp12_)) {
					break;
				}
				_tmp13_ = _record_list;
				_tmp14_ = gee_list_get (_tmp13_, _record_index);
				record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp14_;
				_tmp15_ = record;
				_tmp16_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp17_);
				_tmp19_ = _tmp18_;
				if (_tmp19_ != NULL) {
					has_configuration_intent = TRUE;
					_g_object_unref0 (record);
					break;
				}
				_g_object_unref0 (record);
			}
			_g_object_unref0 (_record_list);
		}
		if (has_configuration_intent) {
			ProtonPlusServicesSteamConfigurationReconciler* _tmp21_;
			_tmp21_ = configuration;
			_tmp20_ = _tmp21_ != NULL;
		} else {
			_tmp20_ = FALSE;
		}
		if (_tmp20_) {
			ProtonPlusServicesSteamConfigurationReconciler* _tmp22_;
			ProtonPlusServicesSteamConfigurationMutation* _tmp23_;
			ProtonPlusServicesSteamConfigurationMutation* _tmp24_;
			_tmp22_ = configuration;
			_tmp23_ = proton_plus_services_steam_configuration_reconciler_reconcile_target (_tmp22_, target);
			_tmp24_ = _tmp23_;
			_g_object_unref0 (_tmp24_);
		}
		_g_object_unref0 (configuration);
		return;
	}
	_tmp25_ = proton_plus_services_steam_session_snapshot_get_state (snapshot);
	_tmp26_ = _tmp25_;
	if (_tmp26_ != PROTON_PLUS_SERVICES_STEAM_SESSION_STATE_RUNNING) {
		return;
	}
	_tmp27_ = proton_plus_services_steam_restart_manager_identity_from_snapshot (self, target, snapshot);
	current = _tmp27_;
	_tmp28_ = current;
	if (_tmp28_ == NULL) {
		_g_object_unref0 (current);
		return;
	}
	configuration_needs_verification = FALSE;
	{
		GeeList* _record_list = NULL;
		GeeList* _tmp29_;
		gint _record_size = 0;
		GeeList* _tmp30_;
		gint _tmp31_;
		gint _tmp32_;
		gint _record_index = 0;
		_tmp29_ = proton_plus_services_steam_restart_manager_get_pending_changes_for_target (self, target);
		_record_list = _tmp29_;
		_tmp30_ = _record_list;
		_tmp31_ = gee_collection_get_size ((GeeCollection*) _tmp30_);
		_tmp32_ = _tmp31_;
		_record_size = _tmp32_;
		_record_index = -1;
		while (TRUE) {
			gint _tmp33_;
			gint _tmp34_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeList* _tmp35_;
			gpointer _tmp36_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp37_;
			ProtonPlusModelsSteamChangeReceipt* _tmp38_;
			ProtonPlusModelsSteamChangeReceipt* _tmp39_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp40_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp41_;
			ProtonPlusModelsSteamSessionIdentity* recorded = NULL;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp42_;
			ProtonPlusModelsSteamSessionIdentity* _tmp43_;
			ProtonPlusModelsSteamSessionIdentity* _tmp44_;
			ProtonPlusModelsSteamSessionIdentity* _tmp45_;
			gboolean _tmp46_ = FALSE;
			gboolean _tmp47_ = FALSE;
			ProtonPlusModelsSteamSessionIdentity* _tmp48_;
			_record_index = _record_index + 1;
			_tmp33_ = _record_index;
			_tmp34_ = _record_size;
			if (!(_tmp33_ < _tmp34_)) {
				break;
			}
			_tmp35_ = _record_list;
			_tmp36_ = gee_list_get (_tmp35_, _record_index);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp36_;
			_tmp37_ = record;
			_tmp38_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp37_);
			_tmp39_ = _tmp38_;
			_tmp40_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp39_);
			_tmp41_ = _tmp40_;
			if (_tmp41_ == NULL) {
				_g_object_unref0 (record);
				continue;
			}
			_tmp42_ = record;
			_tmp43_ = proton_plus_models_steam_restart_pending_record_get_observed_session (_tmp42_);
			_tmp44_ = _tmp43_;
			_tmp45_ = _g_object_ref0 (_tmp44_);
			recorded = _tmp45_;
			_tmp48_ = recorded;
			if (_tmp48_ == NULL) {
				ProtonPlusModelsSteamRestartPendingRecord* _tmp49_;
				gboolean _tmp50_;
				gboolean _tmp51_;
				_tmp49_ = record;
				_tmp50_ = proton_plus_models_steam_restart_pending_record_get_stop_observed (_tmp49_);
				_tmp51_ = _tmp50_;
				_tmp47_ = _tmp51_;
			} else {
				_tmp47_ = FALSE;
			}
			if (_tmp47_) {
				_tmp46_ = TRUE;
			} else {
				gboolean _tmp52_ = FALSE;
				ProtonPlusModelsSteamSessionIdentity* _tmp53_;
				_tmp53_ = recorded;
				if (_tmp53_ != NULL) {
					ProtonPlusModelsSteamSessionIdentity* _tmp54_;
					ProtonPlusModelsSteamSessionIdentity* _tmp55_;
					_tmp54_ = recorded;
					_tmp55_ = current;
					_tmp52_ = !proton_plus_models_steam_session_identity_equals (_tmp54_, G_TYPE_CHECK_INSTANCE_CAST (_tmp55_, PROTON_PLUS_MODELS_TYPE_STEAM_SESSION_IDENTITY, ProtonPlusModelsSteamSessionIdentity));
				} else {
					_tmp52_ = FALSE;
				}
				_tmp46_ = _tmp52_;
			}
			if (_tmp46_) {
				configuration_needs_verification = TRUE;
				_g_object_unref0 (recorded);
				_g_object_unref0 (record);
				break;
			}
			_g_object_unref0 (recorded);
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_list);
	}
	if (configuration_needs_verification) {
		ProtonPlusServicesSteamConfigurationReconciler* configuration = NULL;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp56_;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp57_;
		ProtonPlusServicesSteamConfigurationReconciler* _tmp58_;
		_tmp56_ = self->priv->configuration_reconciler;
		_tmp57_ = _g_object_ref0 (_tmp56_);
		configuration = _tmp57_;
		_tmp58_ = configuration;
		if (_tmp58_ != NULL) {
			ProtonPlusServicesSteamConfigurationReconciler* _tmp59_;
			_tmp59_ = configuration;
			proton_plus_services_steam_configuration_reconciler_verify_target_after_session (_tmp59_, target);
		}
		_g_object_unref0 (configuration);
	}
	_tmp60_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	cleared = _tmp60_;
	{
		GeeList* _record_list = NULL;
		GeeList* _tmp61_;
		gint _record_size = 0;
		GeeList* _tmp62_;
		gint _tmp63_;
		gint _tmp64_;
		gint _record_index = 0;
		_tmp61_ = proton_plus_services_steam_restart_manager_get_pending_changes_for_target (self, target);
		_record_list = _tmp61_;
		_tmp62_ = _record_list;
		_tmp63_ = gee_collection_get_size ((GeeCollection*) _tmp62_);
		_tmp64_ = _tmp63_;
		_record_size = _tmp64_;
		_record_index = -1;
		while (TRUE) {
			gint _tmp65_;
			gint _tmp66_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeList* _tmp67_;
			gpointer _tmp68_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp69_;
			ProtonPlusModelsSteamChangeReceipt* _tmp70_;
			ProtonPlusModelsSteamChangeReceipt* _tmp71_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp72_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp73_;
			ProtonPlusModelsSteamSessionIdentity* recorded = NULL;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp74_;
			ProtonPlusModelsSteamSessionIdentity* _tmp75_;
			ProtonPlusModelsSteamSessionIdentity* _tmp76_;
			ProtonPlusModelsSteamSessionIdentity* _tmp77_;
			gboolean _tmp78_ = FALSE;
			gboolean _tmp79_ = FALSE;
			ProtonPlusModelsSteamSessionIdentity* _tmp80_;
			_record_index = _record_index + 1;
			_tmp65_ = _record_index;
			_tmp66_ = _record_size;
			if (!(_tmp65_ < _tmp66_)) {
				break;
			}
			_tmp67_ = _record_list;
			_tmp68_ = gee_list_get (_tmp67_, _record_index);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp68_;
			_tmp69_ = record;
			_tmp70_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp69_);
			_tmp71_ = _tmp70_;
			_tmp72_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp71_);
			_tmp73_ = _tmp72_;
			if (_tmp73_ != NULL) {
				_g_object_unref0 (record);
				continue;
			}
			_tmp74_ = record;
			_tmp75_ = proton_plus_models_steam_restart_pending_record_get_observed_session (_tmp74_);
			_tmp76_ = _tmp75_;
			_tmp77_ = _g_object_ref0 (_tmp76_);
			recorded = _tmp77_;
			_tmp80_ = recorded;
			if (_tmp80_ == NULL) {
				ProtonPlusModelsSteamRestartPendingRecord* _tmp81_;
				gboolean _tmp82_;
				gboolean _tmp83_;
				_tmp81_ = record;
				_tmp82_ = proton_plus_models_steam_restart_pending_record_get_stop_observed (_tmp81_);
				_tmp83_ = _tmp82_;
				_tmp79_ = _tmp83_;
			} else {
				_tmp79_ = FALSE;
			}
			if (_tmp79_) {
				_tmp78_ = TRUE;
			} else {
				gboolean _tmp84_ = FALSE;
				ProtonPlusModelsSteamSessionIdentity* _tmp85_;
				_tmp85_ = recorded;
				if (_tmp85_ != NULL) {
					ProtonPlusModelsSteamSessionIdentity* _tmp86_;
					ProtonPlusModelsSteamSessionIdentity* _tmp87_;
					_tmp86_ = recorded;
					_tmp87_ = current;
					_tmp84_ = !proton_plus_models_steam_session_identity_equals (_tmp86_, G_TYPE_CHECK_INSTANCE_CAST (_tmp87_, PROTON_PLUS_MODELS_TYPE_STEAM_SESSION_IDENTITY, ProtonPlusModelsSteamSessionIdentity));
				} else {
					_tmp84_ = FALSE;
				}
				_tmp78_ = _tmp84_;
			}
			if (_tmp78_) {
				GeeArrayList* _tmp88_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp89_;
				_tmp88_ = cleared;
				_tmp89_ = record;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp88_, _tmp89_);
			}
			_g_object_unref0 (recorded);
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_list);
	}
	_tmp90_ = cleared;
	_tmp91_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp90_);
	_tmp92_ = _tmp91_;
	if (_tmp92_ == 0) {
		_g_object_unref0 (cleared);
		_g_object_unref0 (current);
		return;
	}
	{
		GeeArrayList* _record_list = NULL;
		GeeArrayList* _tmp93_;
		gint _record_size = 0;
		GeeArrayList* _tmp94_;
		gint _tmp95_;
		gint _tmp96_;
		gint _record_index = 0;
		_tmp93_ = cleared;
		_record_list = _tmp93_;
		_tmp94_ = _record_list;
		_tmp95_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp94_);
		_tmp96_ = _tmp95_;
		_record_size = _tmp96_;
		_record_index = -1;
		while (TRUE) {
			gint _tmp97_;
			gint _tmp98_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeArrayList* _tmp99_;
			gpointer _tmp100_;
			GeeHashMap* _tmp101_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp102_;
			ProtonPlusModelsSteamChangeReceipt* _tmp103_;
			ProtonPlusModelsSteamChangeReceipt* _tmp104_;
			gchar* _tmp105_;
			gchar* _tmp106_;
			gchar* _tmp107_;
			_record_index = _record_index + 1;
			_tmp97_ = _record_index;
			_tmp98_ = _record_size;
			if (!(_tmp97_ < _tmp98_)) {
				break;
			}
			_tmp99_ = _record_list;
			_tmp100_ = gee_abstract_list_get ((GeeAbstractList*) _tmp99_, _record_index);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp100_;
			_tmp101_ = self->priv->pending;
			_tmp102_ = record;
			_tmp103_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp102_);
			_tmp104_ = _tmp103_;
			_tmp105_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp104_);
			_tmp106_ = _tmp105_;
			_tmp107_ = _tmp106_;
			gee_abstract_map_unset ((GeeAbstractMap*) _tmp101_, _tmp107_, NULL);
			_g_free0 (_tmp107_);
			_g_object_unref0 (record);
		}
	}
	target_cleared = proton_plus_services_steam_restart_manager_pending_count_for_target (self, target) == 0;
	if (target_cleared) {
		GeeHashMap* _tmp108_;
		const gchar* _tmp109_;
		const gchar* _tmp110_;
		_tmp108_ = self->priv->targets;
		_tmp109_ = proton_plus_models_steam_restart_target_get_id (target);
		_tmp110_ = _tmp109_;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp108_, _tmp110_, NULL);
	}
	if (!proton_plus_services_steam_restart_manager_persist (self)) {
		GeeHashMap* _tmp127_;
		const gchar* _tmp128_;
		const gchar* _tmp129_;
		{
			GeeArrayList* _record_list = NULL;
			GeeArrayList* _tmp111_;
			gint _record_size = 0;
			GeeArrayList* _tmp112_;
			gint _tmp113_;
			gint _tmp114_;
			gint _record_index = 0;
			_tmp111_ = cleared;
			_record_list = _tmp111_;
			_tmp112_ = _record_list;
			_tmp113_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp112_);
			_tmp114_ = _tmp113_;
			_record_size = _tmp114_;
			_record_index = -1;
			while (TRUE) {
				gint _tmp115_;
				gint _tmp116_;
				ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
				GeeArrayList* _tmp117_;
				gpointer _tmp118_;
				GeeHashMap* _tmp119_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp120_;
				ProtonPlusModelsSteamChangeReceipt* _tmp121_;
				ProtonPlusModelsSteamChangeReceipt* _tmp122_;
				gchar* _tmp123_;
				gchar* _tmp124_;
				gchar* _tmp125_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp126_;
				_record_index = _record_index + 1;
				_tmp115_ = _record_index;
				_tmp116_ = _record_size;
				if (!(_tmp115_ < _tmp116_)) {
					break;
				}
				_tmp117_ = _record_list;
				_tmp118_ = gee_abstract_list_get ((GeeAbstractList*) _tmp117_, _record_index);
				record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp118_;
				_tmp119_ = self->priv->pending;
				_tmp120_ = record;
				_tmp121_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp120_);
				_tmp122_ = _tmp121_;
				_tmp123_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp122_);
				_tmp124_ = _tmp123_;
				_tmp125_ = _tmp124_;
				_tmp126_ = record;
				gee_abstract_map_set ((GeeAbstractMap*) _tmp119_, _tmp125_, _tmp126_);
				_g_free0 (_tmp125_);
				_g_object_unref0 (record);
			}
		}
		_tmp127_ = self->priv->targets;
		_tmp128_ = proton_plus_models_steam_restart_target_get_id (target);
		_tmp129_ = _tmp128_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp127_, _tmp129_, target);
		_g_object_unref0 (cleared);
		_g_object_unref0 (current);
		return;
	}
	g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL], 0);
	if (target_cleared) {
		g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_REQUIREMENT_SATISFIED_SIGNAL], 0, target);
	}
	_g_object_unref0 (cleared);
	_g_object_unref0 (current);
}

gboolean
proton_plus_services_steam_restart_manager_clear_verified_configuration (ProtonPlusServicesSteamRestartManager* self,
                                                                         ProtonPlusModelsSteamRestartPendingRecord* record)
{
	GeeArrayList* records = NULL;
	GeeArrayList* _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (record != NULL, FALSE);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	records = _tmp0_;
	gee_abstract_collection_add ((GeeAbstractCollection*) records, record);
	result = proton_plus_services_steam_restart_manager_clear_verified_configurations (self, (GeeCollection*) records);
	_g_object_unref0 (records);
	return result;
}

gboolean
proton_plus_services_steam_restart_manager_clear_verified_configurations (ProtonPlusServicesSteamRestartManager* self,
                                                                          GeeCollection* records)
{
	gint _tmp0_;
	gint _tmp1_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (records != NULL, FALSE);
	_tmp0_ = gee_collection_get_size (records);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == 0) {
		result = TRUE;
		return result;
	}
	{
		GeeIterator* _record_it = NULL;
		GeeIterator* _tmp2_;
		_tmp2_ = gee_iterable_iterator ((GeeIterable*) records);
		_record_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp6_;
			ProtonPlusModelsSteamChangeReceipt* _tmp7_;
			ProtonPlusModelsSteamChangeReceipt* _tmp8_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp9_;
			ProtonPlusModelsSteamConfigurationIntent* _tmp10_;
			_tmp3_ = _record_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _record_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp5_;
			_tmp6_ = record;
			_tmp7_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = proton_plus_models_steam_change_receipt_get_configuration_intent (_tmp8_);
			_tmp10_ = _tmp9_;
			if (_tmp10_ == NULL) {
				result = FALSE;
				_g_object_unref0 (record);
				_g_object_unref0 (_record_it);
				return result;
			}
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_it);
	}
	result = proton_plus_services_steam_restart_manager_clear_records (self, records);
	return result;
}

static void
proton_plus_services_steam_restart_manager_mark_stop_observed (ProtonPlusServicesSteamRestartManager* self,
                                                               ProtonPlusModelsSteamRestartTarget* target)
{
	gboolean material_change = FALSE;
	g_return_if_fail (self != NULL);
	g_return_if_fail (target != NULL);
	material_change = FALSE;
	{
		GeeList* _record_list = NULL;
		GeeList* _tmp0_;
		gint _record_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _record_index = 0;
		_tmp0_ = proton_plus_services_steam_restart_manager_get_pending_changes_for_target (self, target);
		_record_list = _tmp0_;
		_tmp1_ = _record_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_record_size = _tmp3_;
		_record_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp8_;
			_record_index = _record_index + 1;
			_tmp4_ = _record_index;
			_tmp5_ = _record_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _record_list;
			_tmp7_ = gee_list_get (_tmp6_, _record_index);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp7_;
			_tmp8_ = record;
			material_change |= proton_plus_models_steam_restart_pending_record_mark_stop_observed (_tmp8_);
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_list);
	}
	if (material_change) {
		g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL], 0);
		proton_plus_services_steam_restart_manager_persist (self);
	}
}

static gboolean
proton_plus_services_steam_restart_manager_clear_records (ProtonPlusServicesSteamRestartManager* self,
                                                          GeeCollection* records)
{
	gint _tmp0_;
	gint _tmp1_;
	GeeArrayList* removed = NULL;
	GeeArrayList* _tmp2_;
	GeeHashMap* affected_targets = NULL;
	GeeHashMap* _tmp3_;
	GeeArrayList* cleared_targets = NULL;
	GeeArrayList* _tmp50_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (records != NULL, FALSE);
	_tmp0_ = gee_collection_get_size (records);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == 0) {
		result = TRUE;
		return result;
	}
	_tmp2_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	removed = _tmp2_;
	_tmp3_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_TARGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	affected_targets = _tmp3_;
	{
		GeeIterator* _record_it = NULL;
		GeeIterator* _tmp4_;
		_tmp4_ = gee_iterable_iterator ((GeeIterable*) records);
		_record_it = _tmp4_;
		while (TRUE) {
			GeeIterator* _tmp5_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeIterator* _tmp6_;
			gpointer _tmp7_;
			gchar* key = NULL;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp8_;
			ProtonPlusModelsSteamChangeReceipt* _tmp9_;
			ProtonPlusModelsSteamChangeReceipt* _tmp10_;
			gchar* _tmp11_;
			gchar* _tmp12_;
			ProtonPlusModelsSteamRestartPendingRecord* current = NULL;
			GeeHashMap* _tmp13_;
			const gchar* _tmp14_;
			gpointer _tmp15_;
			gboolean _tmp16_ = FALSE;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp17_;
			GeeArrayList* _tmp20_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp21_;
			GeeHashMap* _tmp22_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp23_;
			ProtonPlusModelsSteamChangeReceipt* _tmp24_;
			ProtonPlusModelsSteamChangeReceipt* _tmp25_;
			ProtonPlusModelsSteamRestartTarget* _tmp26_;
			ProtonPlusModelsSteamRestartTarget* _tmp27_;
			const gchar* _tmp28_;
			const gchar* _tmp29_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp30_;
			ProtonPlusModelsSteamChangeReceipt* _tmp31_;
			ProtonPlusModelsSteamChangeReceipt* _tmp32_;
			ProtonPlusModelsSteamRestartTarget* _tmp33_;
			ProtonPlusModelsSteamRestartTarget* _tmp34_;
			_tmp5_ = _record_it;
			if (!gee_iterator_next (_tmp5_)) {
				break;
			}
			_tmp6_ = _record_it;
			_tmp7_ = gee_iterator_get (_tmp6_);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp7_;
			_tmp8_ = record;
			_tmp9_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp10_);
			_tmp12_ = _tmp11_;
			key = _tmp12_;
			_tmp13_ = self->priv->pending;
			_tmp14_ = key;
			_tmp15_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp13_, _tmp14_);
			current = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp15_;
			_tmp17_ = current;
			if (_tmp17_ == NULL) {
				_tmp16_ = TRUE;
			} else {
				ProtonPlusModelsSteamRestartPendingRecord* _tmp18_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp19_;
				_tmp18_ = current;
				_tmp19_ = record;
				_tmp16_ = _tmp18_ != _tmp19_;
			}
			if (_tmp16_) {
				result = FALSE;
				_g_object_unref0 (current);
				_g_free0 (key);
				_g_object_unref0 (record);
				_g_object_unref0 (_record_it);
				_g_object_unref0 (affected_targets);
				_g_object_unref0 (removed);
				return result;
			}
			_tmp20_ = removed;
			_tmp21_ = record;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp20_, _tmp21_);
			_tmp22_ = affected_targets;
			_tmp23_ = record;
			_tmp24_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp23_);
			_tmp25_ = _tmp24_;
			_tmp26_ = proton_plus_models_steam_change_receipt_get_target (_tmp25_);
			_tmp27_ = _tmp26_;
			_tmp28_ = proton_plus_models_steam_restart_target_get_id (_tmp27_);
			_tmp29_ = _tmp28_;
			_tmp30_ = record;
			_tmp31_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp30_);
			_tmp32_ = _tmp31_;
			_tmp33_ = proton_plus_models_steam_change_receipt_get_target (_tmp32_);
			_tmp34_ = _tmp33_;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp22_, _tmp29_, _tmp34_);
			_g_object_unref0 (current);
			_g_free0 (key);
			_g_object_unref0 (record);
		}
		_g_object_unref0 (_record_it);
	}
	{
		GeeArrayList* _record_list = NULL;
		GeeArrayList* _tmp35_;
		gint _record_size = 0;
		GeeArrayList* _tmp36_;
		gint _tmp37_;
		gint _tmp38_;
		gint _record_index = 0;
		_tmp35_ = removed;
		_record_list = _tmp35_;
		_tmp36_ = _record_list;
		_tmp37_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp36_);
		_tmp38_ = _tmp37_;
		_record_size = _tmp38_;
		_record_index = -1;
		while (TRUE) {
			gint _tmp39_;
			gint _tmp40_;
			ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
			GeeArrayList* _tmp41_;
			gpointer _tmp42_;
			GeeHashMap* _tmp43_;
			ProtonPlusModelsSteamRestartPendingRecord* _tmp44_;
			ProtonPlusModelsSteamChangeReceipt* _tmp45_;
			ProtonPlusModelsSteamChangeReceipt* _tmp46_;
			gchar* _tmp47_;
			gchar* _tmp48_;
			gchar* _tmp49_;
			_record_index = _record_index + 1;
			_tmp39_ = _record_index;
			_tmp40_ = _record_size;
			if (!(_tmp39_ < _tmp40_)) {
				break;
			}
			_tmp41_ = _record_list;
			_tmp42_ = gee_abstract_list_get ((GeeAbstractList*) _tmp41_, _record_index);
			record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp42_;
			_tmp43_ = self->priv->pending;
			_tmp44_ = record;
			_tmp45_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp44_);
			_tmp46_ = _tmp45_;
			_tmp47_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp46_);
			_tmp48_ = _tmp47_;
			_tmp49_ = _tmp48_;
			gee_abstract_map_unset ((GeeAbstractMap*) _tmp43_, _tmp49_, NULL);
			_g_free0 (_tmp49_);
			_g_object_unref0 (record);
		}
	}
	_tmp50_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_TARGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	cleared_targets = _tmp50_;
	{
		GeeIterator* _target_it = NULL;
		GeeHashMap* _tmp51_;
		GeeCollection* _tmp52_;
		GeeCollection* _tmp53_;
		GeeCollection* _tmp54_;
		GeeIterator* _tmp55_;
		GeeIterator* _tmp56_;
		_tmp51_ = affected_targets;
		_tmp52_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp51_);
		_tmp53_ = _tmp52_;
		_tmp54_ = _tmp53_;
		_tmp55_ = gee_iterable_iterator ((GeeIterable*) _tmp54_);
		_tmp56_ = _tmp55_;
		_g_object_unref0 (_tmp54_);
		_target_it = _tmp56_;
		while (TRUE) {
			GeeIterator* _tmp57_;
			ProtonPlusModelsSteamRestartTarget* target = NULL;
			GeeIterator* _tmp58_;
			gpointer _tmp59_;
			ProtonPlusModelsSteamRestartTarget* _tmp60_;
			_tmp57_ = _target_it;
			if (!gee_iterator_next (_tmp57_)) {
				break;
			}
			_tmp58_ = _target_it;
			_tmp59_ = gee_iterator_get (_tmp58_);
			target = (ProtonPlusModelsSteamRestartTarget*) _tmp59_;
			_tmp60_ = target;
			if (proton_plus_services_steam_restart_manager_pending_count_for_target (self, _tmp60_) == 0) {
				GeeHashMap* _tmp61_;
				ProtonPlusModelsSteamRestartTarget* _tmp62_;
				const gchar* _tmp63_;
				const gchar* _tmp64_;
				GeeArrayList* _tmp65_;
				ProtonPlusModelsSteamRestartTarget* _tmp66_;
				_tmp61_ = self->priv->targets;
				_tmp62_ = target;
				_tmp63_ = proton_plus_models_steam_restart_target_get_id (_tmp62_);
				_tmp64_ = _tmp63_;
				gee_abstract_map_unset ((GeeAbstractMap*) _tmp61_, _tmp64_, NULL);
				_tmp65_ = cleared_targets;
				_tmp66_ = target;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp65_, _tmp66_);
			}
			_g_object_unref0 (target);
		}
		_g_object_unref0 (_target_it);
	}
	if (!proton_plus_services_steam_restart_manager_persist (self)) {
		{
			GeeArrayList* _record_list = NULL;
			GeeArrayList* _tmp67_;
			gint _record_size = 0;
			GeeArrayList* _tmp68_;
			gint _tmp69_;
			gint _tmp70_;
			gint _record_index = 0;
			_tmp67_ = removed;
			_record_list = _tmp67_;
			_tmp68_ = _record_list;
			_tmp69_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp68_);
			_tmp70_ = _tmp69_;
			_record_size = _tmp70_;
			_record_index = -1;
			while (TRUE) {
				gint _tmp71_;
				gint _tmp72_;
				ProtonPlusModelsSteamRestartPendingRecord* record = NULL;
				GeeArrayList* _tmp73_;
				gpointer _tmp74_;
				GeeHashMap* _tmp75_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp76_;
				ProtonPlusModelsSteamChangeReceipt* _tmp77_;
				ProtonPlusModelsSteamChangeReceipt* _tmp78_;
				gchar* _tmp79_;
				gchar* _tmp80_;
				gchar* _tmp81_;
				ProtonPlusModelsSteamRestartPendingRecord* _tmp82_;
				_record_index = _record_index + 1;
				_tmp71_ = _record_index;
				_tmp72_ = _record_size;
				if (!(_tmp71_ < _tmp72_)) {
					break;
				}
				_tmp73_ = _record_list;
				_tmp74_ = gee_abstract_list_get ((GeeAbstractList*) _tmp73_, _record_index);
				record = (ProtonPlusModelsSteamRestartPendingRecord*) _tmp74_;
				_tmp75_ = self->priv->pending;
				_tmp76_ = record;
				_tmp77_ = proton_plus_models_steam_restart_pending_record_get_receipt (_tmp76_);
				_tmp78_ = _tmp77_;
				_tmp79_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp78_);
				_tmp80_ = _tmp79_;
				_tmp81_ = _tmp80_;
				_tmp82_ = record;
				gee_abstract_map_set ((GeeAbstractMap*) _tmp75_, _tmp81_, _tmp82_);
				_g_free0 (_tmp81_);
				_g_object_unref0 (record);
			}
		}
		{
			GeeIterator* _target_it = NULL;
			GeeHashMap* _tmp83_;
			GeeCollection* _tmp84_;
			GeeCollection* _tmp85_;
			GeeCollection* _tmp86_;
			GeeIterator* _tmp87_;
			GeeIterator* _tmp88_;
			_tmp83_ = affected_targets;
			_tmp84_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp83_);
			_tmp85_ = _tmp84_;
			_tmp86_ = _tmp85_;
			_tmp87_ = gee_iterable_iterator ((GeeIterable*) _tmp86_);
			_tmp88_ = _tmp87_;
			_g_object_unref0 (_tmp86_);
			_target_it = _tmp88_;
			while (TRUE) {
				GeeIterator* _tmp89_;
				ProtonPlusModelsSteamRestartTarget* target = NULL;
				GeeIterator* _tmp90_;
				gpointer _tmp91_;
				GeeHashMap* _tmp92_;
				ProtonPlusModelsSteamRestartTarget* _tmp93_;
				const gchar* _tmp94_;
				const gchar* _tmp95_;
				ProtonPlusModelsSteamRestartTarget* _tmp96_;
				_tmp89_ = _target_it;
				if (!gee_iterator_next (_tmp89_)) {
					break;
				}
				_tmp90_ = _target_it;
				_tmp91_ = gee_iterator_get (_tmp90_);
				target = (ProtonPlusModelsSteamRestartTarget*) _tmp91_;
				_tmp92_ = self->priv->targets;
				_tmp93_ = target;
				_tmp94_ = proton_plus_models_steam_restart_target_get_id (_tmp93_);
				_tmp95_ = _tmp94_;
				_tmp96_ = target;
				gee_abstract_map_set ((GeeAbstractMap*) _tmp92_, _tmp95_, _tmp96_);
				_g_object_unref0 (target);
			}
			_g_object_unref0 (_target_it);
		}
		result = FALSE;
		_g_object_unref0 (cleared_targets);
		_g_object_unref0 (affected_targets);
		_g_object_unref0 (removed);
		return result;
	}
	g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL], 0);
	{
		GeeArrayList* _target_list = NULL;
		GeeArrayList* _tmp97_;
		gint _target_size = 0;
		GeeArrayList* _tmp98_;
		gint _tmp99_;
		gint _tmp100_;
		gint _target_index = 0;
		_tmp97_ = cleared_targets;
		_target_list = _tmp97_;
		_tmp98_ = _target_list;
		_tmp99_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp98_);
		_tmp100_ = _tmp99_;
		_target_size = _tmp100_;
		_target_index = -1;
		while (TRUE) {
			gint _tmp101_;
			gint _tmp102_;
			ProtonPlusModelsSteamRestartTarget* target = NULL;
			GeeArrayList* _tmp103_;
			gpointer _tmp104_;
			ProtonPlusModelsSteamRestartTarget* _tmp105_;
			_target_index = _target_index + 1;
			_tmp101_ = _target_index;
			_tmp102_ = _target_size;
			if (!(_tmp101_ < _tmp102_)) {
				break;
			}
			_tmp103_ = _target_list;
			_tmp104_ = gee_abstract_list_get ((GeeAbstractList*) _tmp103_, _target_index);
			target = (ProtonPlusModelsSteamRestartTarget*) _tmp104_;
			_tmp105_ = target;
			g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_REQUIREMENT_SATISFIED_SIGNAL], 0, _tmp105_);
			_g_object_unref0 (target);
		}
	}
	result = TRUE;
	_g_object_unref0 (cleared_targets);
	_g_object_unref0 (affected_targets);
	_g_object_unref0 (removed);
	return result;
}

static void
proton_plus_services_steam_restart_manager_add_loaded_record (ProtonPlusServicesSteamRestartManager* self,
                                                              ProtonPlusModelsSteamRestartPendingRecord* record)
{
	gchar* key = NULL;
	ProtonPlusModelsSteamChangeReceipt* _tmp0_;
	ProtonPlusModelsSteamChangeReceipt* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GeeHashMap* _tmp4_;
	const gchar* _tmp5_;
	GeeHashMap* _tmp6_;
	const gchar* _tmp7_;
	GeeHashMap* _tmp8_;
	ProtonPlusModelsSteamChangeReceipt* _tmp9_;
	ProtonPlusModelsSteamChangeReceipt* _tmp10_;
	ProtonPlusModelsSteamRestartTarget* _tmp11_;
	ProtonPlusModelsSteamRestartTarget* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	ProtonPlusModelsSteamChangeReceipt* _tmp15_;
	ProtonPlusModelsSteamChangeReceipt* _tmp16_;
	ProtonPlusModelsSteamRestartTarget* _tmp17_;
	ProtonPlusModelsSteamRestartTarget* _tmp18_;
	ProtonPlusModelsSteamChangeReceipt* _tmp19_;
	ProtonPlusModelsSteamChangeReceipt* _tmp20_;
	ProtonPlusModelsSteamRestartTarget* _tmp21_;
	ProtonPlusModelsSteamRestartTarget* _tmp22_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (record != NULL);
	_tmp0_ = proton_plus_models_steam_restart_pending_record_get_receipt (record);
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_models_steam_change_receipt_get_deduplication_key (_tmp1_);
	_tmp3_ = _tmp2_;
	key = _tmp3_;
	_tmp4_ = self->priv->pending;
	_tmp5_ = key;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp4_, _tmp5_)) {
		_g_free0 (key);
		return;
	}
	_tmp6_ = self->priv->pending;
	_tmp7_ = key;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp6_, _tmp7_, record);
	_tmp8_ = self->priv->targets;
	_tmp9_ = proton_plus_models_steam_restart_pending_record_get_receipt (record);
	_tmp10_ = _tmp9_;
	_tmp11_ = proton_plus_models_steam_change_receipt_get_target (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = proton_plus_models_steam_restart_target_get_id (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = proton_plus_models_steam_restart_pending_record_get_receipt (record);
	_tmp16_ = _tmp15_;
	_tmp17_ = proton_plus_models_steam_change_receipt_get_target (_tmp16_);
	_tmp18_ = _tmp17_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp8_, _tmp14_, _tmp18_);
	_tmp19_ = proton_plus_models_steam_restart_pending_record_get_receipt (record);
	_tmp20_ = _tmp19_;
	_tmp21_ = proton_plus_models_steam_change_receipt_get_target (_tmp20_);
	_tmp22_ = _tmp21_;
	proton_plus_services_steam_restart_manager_watch_target (self, _tmp22_);
	_g_free0 (key);
}

static ProtonPlusModelsSteamRestartPendingRecord*
proton_plus_services_steam_restart_manager_updated_record (ProtonPlusServicesSteamRestartManager* self,
                                                           ProtonPlusModelsSteamRestartPendingRecord* old,
                                                           ProtonPlusModelsSteamChangeReceipt* receipt,
                                                           ProtonPlusModelsSteamSessionIdentity* session)
{
	ProtonPlusModelsSteamSessionIdentity* observed = NULL;
	ProtonPlusModelsSteamSessionIdentity* _tmp0_;
	ProtonPlusModelsSteamSessionIdentity* _tmp1_;
	ProtonPlusModelsSteamSessionIdentity* _tmp2_;
	gboolean _tmp3_ = FALSE;
	ProtonPlusModelsSteamSessionIdentity* _tmp4_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	guint _tmp10_;
	guint _tmp11_;
	ProtonPlusModelsSteamSessionIdentity* _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_;
	ProtonPlusModelsSteamRestartPendingRecord* _tmp15_;
	ProtonPlusModelsSteamRestartPendingRecord* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (receipt != NULL, NULL);
	_tmp0_ = proton_plus_models_steam_restart_pending_record_get_observed_session (old);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	observed = _tmp2_;
	_tmp4_ = observed;
	if (_tmp4_ == NULL) {
		_tmp3_ = session != NULL;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		ProtonPlusModelsSteamSessionIdentity* _tmp5_;
		_tmp5_ = _g_object_ref0 (session);
		_g_object_unref0 (observed);
		observed = _tmp5_;
	}
	_tmp6_ = proton_plus_models_steam_restart_pending_record_get_first_recorded_at (old);
	_tmp7_ = _tmp6_;
	_tmp8_ = proton_plus_models_steam_change_receipt_get_changed_at (receipt);
	_tmp9_ = _tmp8_;
	_tmp10_ = proton_plus_models_steam_restart_pending_record_get_occurrence_count (old);
	_tmp11_ = _tmp10_;
	_tmp12_ = observed;
	_tmp13_ = proton_plus_models_steam_restart_pending_record_get_stop_observed (old);
	_tmp14_ = _tmp13_;
	_tmp15_ = proton_plus_models_steam_restart_pending_record_new (receipt, _tmp7_, _tmp9_, _tmp11_ + 1, _tmp12_, _tmp14_);
	result = _tmp15_;
	_g_object_unref0 (observed);
	return result;
}

static void
proton_plus_services_steam_restart_manager_watch_target (ProtonPlusServicesSteamRestartManager* self,
                                                         ProtonPlusModelsSteamRestartTarget* target)
{
	ProtonPlusServicesSteamSessionService* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (target != NULL);
	_tmp0_ = self->priv->session_service;
	proton_plus_services_steam_session_service_watch_target (_tmp0_, target);
}

static gboolean
proton_plus_services_steam_restart_manager_persist (ProtonPlusServicesSteamRestartManager* self)
{
	ProtonPlusServicesSteamRestartStateStore* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	gboolean _tmp5_;
	const gchar* _tmp6_ = NULL;
	ProtonPlusServicesSteamRestartStateStore* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->state_store;
	_tmp1_ = self->priv->pending;
	_tmp2_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = proton_plus_services_steam_restart_state_store_save (_tmp0_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	if (_tmp5_) {
		proton_plus_services_steam_restart_manager_set_last_persistence_error (self, NULL);
		result = TRUE;
		return result;
	}
	_tmp7_ = self->priv->state_store;
	_tmp8_ = proton_plus_services_steam_restart_state_store_get_last_error (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp6_ = _tmp9_;
	if (_tmp6_ == NULL) {
		_tmp6_ = "Unable to save Steam restart state.";
	}
	proton_plus_services_steam_restart_manager_set_last_persistence_error (self, _tmp6_);
	_tmp10_ = self->priv->_last_persistence_error;
	g_signal_emit (self, proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PERSISTENCE_FAILED_SIGNAL], 0, (const gchar*) _tmp10_);
	result = FALSE;
	return result;
}

static gboolean
proton_plus_services_steam_restart_manager_is_confirmed_stopped (ProtonPlusServicesSteamRestartManager* self,
                                                                 ProtonPlusServicesSteamSessionSnapshot* snapshot)
{
	gboolean _tmp0_ = FALSE;
	ProtonPlusServicesSteamSessionState _tmp1_;
	ProtonPlusServicesSteamSessionState _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (snapshot != NULL, FALSE);
	_tmp1_ = proton_plus_services_steam_session_snapshot_get_state (snapshot);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == PROTON_PLUS_SERVICES_STEAM_SESSION_STATE_STOPPED) {
		ProtonPlusServicesSteamEvidenceLevel _tmp3_;
		ProtonPlusServicesSteamEvidenceLevel _tmp4_;
		_tmp3_ = proton_plus_services_steam_session_snapshot_get_state_confidence (snapshot);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == PROTON_PLUS_SERVICES_STEAM_EVIDENCE_LEVEL_CONFIRMED;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static ProtonPlusModelsSteamSessionIdentity*
proton_plus_services_steam_restart_manager_identity_from_snapshot (ProtonPlusServicesSteamRestartManager* self,
                                                                   ProtonPlusModelsSteamRestartTarget* target,
                                                                   ProtonPlusServicesSteamSessionSnapshot* snapshot)
{
	gboolean _tmp0_ = FALSE;
	ProtonPlusServicesSteamSessionState _tmp1_;
	ProtonPlusServicesSteamSessionState _tmp2_;
	ProtonPlusModelsSteamInstallationKind _tmp5_;
	ProtonPlusModelsSteamInstallationKind _tmp6_;
	ProtonPlusServicesSteamProcessGeneration* generation = NULL;
	ProtonPlusServicesSteamProcessGeneration* _tmp15_;
	ProtonPlusServicesSteamProcessGeneration* _tmp16_;
	ProtonPlusServicesSteamProcessGeneration* _tmp17_;
	gboolean _tmp18_ = FALSE;
	gboolean _tmp19_ = FALSE;
	gboolean _tmp20_ = FALSE;
	gboolean _tmp21_ = FALSE;
	ProtonPlusServicesSteamProcessGeneration* _tmp22_;
	ProtonPlusServicesSteamProcessGeneration* _tmp35_;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	ProtonPlusServicesSteamProcessGeneration* _tmp38_;
	gint64 _tmp39_;
	gint64 _tmp40_;
	ProtonPlusServicesSteamProcessGeneration* _tmp41_;
	gint _tmp42_;
	gint _tmp43_;
	ProtonPlusModelsSteamSessionIdentity* _tmp44_;
	ProtonPlusModelsSteamSessionIdentity* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (target != NULL, NULL);
	g_return_val_if_fail (snapshot != NULL, NULL);
	_tmp1_ = proton_plus_services_steam_session_snapshot_get_state (snapshot);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != PROTON_PLUS_SERVICES_STEAM_SESSION_STATE_RUNNING) {
		_tmp0_ = TRUE;
	} else {
		ProtonPlusServicesSteamEvidenceLevel _tmp3_;
		ProtonPlusServicesSteamEvidenceLevel _tmp4_;
		_tmp3_ = proton_plus_services_steam_session_snapshot_get_state_confidence (snapshot);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ != PROTON_PLUS_SERVICES_STEAM_EVIDENCE_LEVEL_CONFIRMED;
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp5_ = proton_plus_models_steam_restart_target_get_installation_kind (target);
	_tmp6_ = _tmp5_;
	if (_tmp6_ == PROTON_PLUS_MODELS_STEAM_INSTALLATION_KIND_FLATPAK) {
		gboolean _tmp7_ = FALSE;
		const gchar* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		ProtonPlusModelsSteamSessionIdentity* _tmp14_;
		_tmp8_ = proton_plus_services_steam_session_snapshot_get_flatpak_instance_id (snapshot);
		_tmp9_ = _tmp8_;
		if (_tmp9_ == NULL) {
			_tmp7_ = TRUE;
		} else {
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			_tmp10_ = proton_plus_services_steam_session_snapshot_get_flatpak_instance_id (snapshot);
			_tmp11_ = _tmp10_;
			_tmp7_ = g_strcmp0 (_tmp11_, "") == 0;
		}
		if (_tmp7_) {
			result = NULL;
			return result;
		}
		_tmp12_ = proton_plus_services_steam_session_snapshot_get_flatpak_instance_id (snapshot);
		_tmp13_ = _tmp12_;
		_tmp14_ = proton_plus_models_steam_session_identity_new (NULL, (gint64) 0, 0, _tmp13_);
		result = _tmp14_;
		return result;
	}
	_tmp15_ = proton_plus_services_steam_session_snapshot_get_generation (snapshot);
	_tmp16_ = _tmp15_;
	_tmp17_ = _g_object_ref0 (_tmp16_);
	generation = _tmp17_;
	_tmp22_ = generation;
	if (_tmp22_ == NULL) {
		_tmp21_ = TRUE;
	} else {
		ProtonPlusServicesSteamProcessGeneration* _tmp23_;
		const gchar* _tmp24_;
		const gchar* _tmp25_;
		_tmp23_ = generation;
		_tmp24_ = proton_plus_services_steam_process_generation_get_boot_id (_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp21_ = _tmp25_ == NULL;
	}
	if (_tmp21_) {
		_tmp20_ = TRUE;
	} else {
		ProtonPlusServicesSteamProcessGeneration* _tmp26_;
		const gchar* _tmp27_;
		const gchar* _tmp28_;
		_tmp26_ = generation;
		_tmp27_ = proton_plus_services_steam_process_generation_get_boot_id (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp20_ = g_strcmp0 (_tmp28_, "") == 0;
	}
	if (_tmp20_) {
		_tmp19_ = TRUE;
	} else {
		ProtonPlusServicesSteamProcessGeneration* _tmp29_;
		gint64 _tmp30_;
		gint64 _tmp31_;
		_tmp29_ = generation;
		_tmp30_ = proton_plus_services_steam_process_generation_get_start_time_ticks (_tmp29_);
		_tmp31_ = _tmp30_;
		_tmp19_ = _tmp31_ <= ((gint64) 0);
	}
	if (_tmp19_) {
		_tmp18_ = TRUE;
	} else {
		ProtonPlusServicesSteamProcessGeneration* _tmp32_;
		gint _tmp33_;
		gint _tmp34_;
		_tmp32_ = generation;
		_tmp33_ = proton_plus_services_steam_process_generation_get_pid (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp18_ = _tmp34_ <= 0;
	}
	if (_tmp18_) {
		result = NULL;
		_g_object_unref0 (generation);
		return result;
	}
	_tmp35_ = generation;
	_tmp36_ = proton_plus_services_steam_process_generation_get_boot_id (_tmp35_);
	_tmp37_ = _tmp36_;
	_tmp38_ = generation;
	_tmp39_ = proton_plus_services_steam_process_generation_get_start_time_ticks (_tmp38_);
	_tmp40_ = _tmp39_;
	_tmp41_ = generation;
	_tmp42_ = proton_plus_services_steam_process_generation_get_pid (_tmp41_);
	_tmp43_ = _tmp42_;
	_tmp44_ = proton_plus_models_steam_session_identity_new (_tmp37_, _tmp40_, _tmp43_, NULL);
	result = _tmp44_;
	_g_object_unref0 (generation);
	return result;
}

const gchar*
proton_plus_services_steam_restart_manager_get_last_persistence_error (ProtonPlusServicesSteamRestartManager* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_last_persistence_error;
	result = _tmp0_;
	return result;
}

static void
proton_plus_services_steam_restart_manager_set_last_persistence_error (ProtonPlusServicesSteamRestartManager* self,
                                                                       const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_services_steam_restart_manager_get_last_persistence_error (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_last_persistence_error);
		self->priv->_last_persistence_error = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_services_steam_restart_manager_properties[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_PERSISTENCE_ERROR_PROPERTY]);
	}
}

const gchar*
proton_plus_services_steam_restart_manager_get_last_load_error (ProtonPlusServicesSteamRestartManager* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_last_load_error;
	result = _tmp0_;
	return result;
}

static void
proton_plus_services_steam_restart_manager_set_last_load_error (ProtonPlusServicesSteamRestartManager* self,
                                                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_services_steam_restart_manager_get_last_load_error (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_last_load_error);
		self->priv->_last_load_error = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_services_steam_restart_manager_properties[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_LOAD_ERROR_PROPERTY]);
	}
}

gboolean
proton_plus_services_steam_restart_manager_get_is_observing (ProtonPlusServicesSteamRestartManager* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->observation_started;
	return result;
}

static void
proton_plus_services_steam_restart_manager_class_init (ProtonPlusServicesSteamRestartManagerClass * klass,
                                                       gpointer klass_data)
{
	proton_plus_services_steam_restart_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusServicesSteamRestartManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_services_steam_restart_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_services_steam_restart_manager_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_services_steam_restart_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_PERSISTENCE_ERROR_PROPERTY, proton_plus_services_steam_restart_manager_properties[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_PERSISTENCE_ERROR_PROPERTY] = g_param_spec_string ("last-persistence-error", "last-persistence-error", "last-persistence-error", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_LOAD_ERROR_PROPERTY, proton_plus_services_steam_restart_manager_properties[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_LOAD_ERROR_PROPERTY] = g_param_spec_string ("last-load-error", "last-load-error", "last-load-error", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_IS_OBSERVING_PROPERTY, proton_plus_services_steam_restart_manager_properties[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_IS_OBSERVING_PROPERTY] = g_param_spec_boolean ("is-observing", "is-observing", "is-observing", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PENDING_CHANGED_SIGNAL] = g_signal_new ("pending-changed", PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_BECAME_REQUIRED_SIGNAL] = g_signal_new ("restart-became-required", PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_TARGET);
	proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_RESTART_REQUIREMENT_SATISFIED_SIGNAL] = g_signal_new ("restart-requirement-satisfied", PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_TARGET);
	proton_plus_services_steam_restart_manager_signals[PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_PERSISTENCE_FAILED_SIGNAL] = g_signal_new ("persistence-failed", PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static void
proton_plus_services_steam_restart_manager_proton_plus_services_steam_change_recorder_interface_init (ProtonPlusServicesSteamChangeRecorderIface * iface,
                                                                                                      gpointer iface_data)
{
	proton_plus_services_steam_restart_manager_proton_plus_services_steam_change_recorder_parent_iface = g_type_interface_peek_parent (iface);
	iface->record = (ProtonPlusServicesSteamRestartRecordResult (*) (ProtonPlusServicesSteamChangeRecorder*, ProtonPlusModelsSteamChangeReceipt*)) proton_plus_services_steam_restart_manager_real_record;
}

static void
proton_plus_services_steam_restart_manager_instance_init (ProtonPlusServicesSteamRestartManager * self,
                                                          gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	self->priv = proton_plus_services_steam_restart_manager_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_PENDING_RECORD, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->pending = _tmp0_;
	_tmp1_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, PROTON_PLUS_MODELS_TYPE_STEAM_RESTART_TARGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->targets = _tmp1_;
	self->priv->state_changed_handler_id = (gulong) 0;
	self->priv->observation_started = FALSE;
	self->priv->_last_persistence_error = NULL;
	self->priv->_last_load_error = NULL;
}

static void
proton_plus_services_steam_restart_manager_finalize (GObject * obj)
{
	ProtonPlusServicesSteamRestartManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, ProtonPlusServicesSteamRestartManager);
	proton_plus_services_steam_restart_manager_stop_observation (self);
	_g_object_unref0 (self->priv->session_service);
	_g_object_unref0 (self->priv->state_store);
	_g_object_unref0 (self->priv->pending);
	_g_object_unref0 (self->priv->targets);
	_g_object_unref0 (self->priv->configuration_reconciler);
	_g_free0 (self->priv->_last_persistence_error);
	_g_free0 (self->priv->_last_load_error);
	G_OBJECT_CLASS (proton_plus_services_steam_restart_manager_parent_class)->finalize (obj);
}

static GType
proton_plus_services_steam_restart_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusServicesSteamRestartManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_services_steam_restart_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusServicesSteamRestartManager), 0, (GInstanceInitFunc) proton_plus_services_steam_restart_manager_instance_init, NULL };
	static const GInterfaceInfo proton_plus_services_steam_change_recorder_info = { (GInterfaceInitFunc) proton_plus_services_steam_restart_manager_proton_plus_services_steam_change_recorder_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType proton_plus_services_steam_restart_manager_type_id;
	proton_plus_services_steam_restart_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusServicesSteamRestartManager", &g_define_type_info, 0);
	g_type_add_interface_static (proton_plus_services_steam_restart_manager_type_id, PROTON_PLUS_SERVICES_TYPE_STEAM_CHANGE_RECORDER, &proton_plus_services_steam_change_recorder_info);
	ProtonPlusServicesSteamRestartManager_private_offset = g_type_add_instance_private (proton_plus_services_steam_restart_manager_type_id, sizeof (ProtonPlusServicesSteamRestartManagerPrivate));
	return proton_plus_services_steam_restart_manager_type_id;
}

GType
proton_plus_services_steam_restart_manager_get_type (void)
{
	static volatile gsize proton_plus_services_steam_restart_manager_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_services_steam_restart_manager_type_id__once)) {
		GType proton_plus_services_steam_restart_manager_type_id;
		proton_plus_services_steam_restart_manager_type_id = proton_plus_services_steam_restart_manager_get_type_once ();
		g_once_init_leave (&proton_plus_services_steam_restart_manager_type_id__once, proton_plus_services_steam_restart_manager_type_id);
	}
	return proton_plus_services_steam_restart_manager_type_id__once;
}

static void
_vala_proton_plus_services_steam_restart_manager_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec)
{
	ProtonPlusServicesSteamRestartManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, ProtonPlusServicesSteamRestartManager);
	switch (property_id) {
		case PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_PERSISTENCE_ERROR_PROPERTY:
		g_value_set_string (value, proton_plus_services_steam_restart_manager_get_last_persistence_error (self));
		break;
		case PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_LOAD_ERROR_PROPERTY:
		g_value_set_string (value, proton_plus_services_steam_restart_manager_get_last_load_error (self));
		break;
		case PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_IS_OBSERVING_PROPERTY:
		g_value_set_boolean (value, proton_plus_services_steam_restart_manager_get_is_observing (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_services_steam_restart_manager_set_property (GObject * object,
                                                               guint property_id,
                                                               const GValue * value,
                                                               GParamSpec * pspec)
{
	ProtonPlusServicesSteamRestartManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_SERVICES_TYPE_STEAM_RESTART_MANAGER, ProtonPlusServicesSteamRestartManager);
	switch (property_id) {
		case PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_PERSISTENCE_ERROR_PROPERTY:
		proton_plus_services_steam_restart_manager_set_last_persistence_error (self, g_value_get_string (value));
		break;
		case PROTON_PLUS_SERVICES_STEAM_RESTART_MANAGER_LAST_LOAD_ERROR_PROPERTY:
		proton_plus_services_steam_restart_manager_set_last_load_error (self, g_value_get_string (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;
}

