establish_administrative_region = {
	category = influence

	require_acceptance = no

	is_visible = {
		can_create_subject_type = {
			subject = FROM
			subject_type = administrative_region
		}
	}

	is_allowed = {
		can_create_subject_type = {
			subject = FROM
			subject_type = administrative_region
		}
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = { NOT = { liberty_desire = 50 } }
		NOT = { truce_with = FROM }
	}

	on_accept = {
		if = {
			limit = {
				can_create_subject_type = {
					subject = FROM
					subject_type = administrative_region
				}
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = { NOT = { liberty_desire = 50 } }
				NOT = { truce_with = FROM }
			}
			create_subject = {
				subject = FROM
				subject_type = administrative_region
				keep_liberty_desire = yes
			}
		}
	}

	ai_will_do = {
		calc_true_if = {
			all_subject_country = {
				is_vassal_or_similar_subject = yes
			}
			amount = 3
		}
		FROM = {
			NOT = { total_development = 100 }
		}
	}
}

administrative_region_remove_heir = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = administrative_region
			government = monarchy
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = administrative_region
				government = monarchy
			}
		}
		is_at_war = no
		FROM = { is_at_war = no }
		FROM = { NOT = { liberty_desire = 50 } }
		FROM = {
			has_regency = no
		}
		FROM = {
			has_heir = yes
		}
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = administrative_region
					government = monarchy
				}
				is_at_war = no
				FROM = { is_at_war = no }
				FROM = { NOT = { liberty_desire = 50 } }
				FROM = {
					has_regency = no
				}
				FROM = {
					has_heir = yes
				}
			}
			FROM = {
				set_ruler_flag = administrative_region_remove_heir
				country_event = { id = subjects_expanded_administrative_region_events.3 }
			}
		}
	}

	ai_will_do = {
		FROM = {
			NOT = { has_ruler_flag = administrative_region_remove_heir }
			NOT = { liberty_desire = 25 }
			OR = {
				AND = {
					NOT = { heir_adm = 3 }
					NOT = { heir_dip = 3 }
					NOT = { heir_mil = 3 }
				}
				AND = {
					NOT = { heir_adm = 1 }
					NOT = { heir_dip = 4 }
					NOT = { heir_mil = 4 }
				}
				AND = {
					NOT = { heir_adm = 4 }
					NOT = { heir_dip = 1 }
					NOT = { heir_mil = 4 }
				}
				AND = {
					NOT = { heir_adm = 4 }
					NOT = { heir_dip = 4 }
					NOT = { heir_mil = 1 }
				}
			}
		}
	}
}

administrative_region_enable_administrative_help = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = administrative_region
			NOT = { has_country_flag = administrative_region_enable_administrative_help }
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = administrative_region
				NOT = { has_country_flag = administrative_region_enable_administrative_help }
			}
		}
		is_at_war = no
		NOT = { truce_with = FROM }
		FROM = { is_at_war = no }
		FROM = { NOT = { liberty_desire = 50 } }
		FROM = {
			has_regency = no
		}
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = administrative_region
					NOT = { has_country_flag = administrative_region_enable_administrative_help }
				}
				is_at_war = no
				NOT = { truce_with = FROM }
				FROM = { is_at_war = no }
				FROM = { NOT = { liberty_desire = 50 } }
				FROM = {
					has_regency = no
				}
			}
			FROM = {
				set_country_flag = administrative_region_enable_administrative_help
				add_opinion = {
					who = ROOT
					modifier = administrative_region_enable_administrative_help_opinion
				}
			}
		}
	}

	ai_will_do = {
		has_regency = no
		OR = {
			NOT = { ADM = 1 }
			NOT = { DIP = 1 }
			NOT = { MIL = 1 }
		}
		FROM = {
			NOT = { liberty_desire = 5 }
		}
	}
}

administrative_region_disable_administrative_help = {
	category = subject_interactions

	require_acceptance = no

	is_visible = {
		FROM = {
			is_subject_of = ROOT
			is_subject_of_type = administrative_region
			has_country_flag = administrative_region_enable_administrative_help
		}
	}

	is_allowed = {
		hidden_trigger = {
			FROM = {
				is_subject_of = ROOT
				is_subject_of_type = administrative_region
				has_country_flag = administrative_region_enable_administrative_help
			}
		}
		has_regency = no
	}

	on_accept = {
		if = {
			limit = {
				FROM = {
					is_subject_of = ROOT
					is_subject_of_type = administrative_region
					has_country_flag = administrative_region_enable_administrative_help
				}
				has_regency = no
			}
			FROM = {
				clr_country_flag = administrative_region_enable_administrative_help
				add_liberty_desire = 40
			}
		}
	}

	ai_will_do = {
		FROM = {
			liberty_desire = 55
		}
	}
}