set_up_random_available_imperial_diet_subject = {
	random_list = {
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_support_free_cities }
				OR = {
					AND = {
						is_part_of_hre = yes
						has_reform = free_city
					}
					any_country = {
						is_part_of_hre = yes
						has_reform = free_city
					}
				}
			}
			set_global_flag = imperial_diet_subject_support_free_cities
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_support_margraviates }
				OR = {
					AND = {
						is_part_of_hre = yes
						total_development = 50
						OR = {
							is_subject = no
							overlord = {
								is_part_of_hre = yes
							}
						}
						OR = {
							is_subject_of_type = march
							has_reform = imperial_march_reform # Extended Timeline
							has_reform = margrave_reform # Governments Expanded
							any_neighbor_country = {
								is_subject = no
								is_part_of_hre = no
								army_size = PREV
								total_development = PREV
							}
						}
					}
					any_country = {
						is_part_of_hre = yes
						total_development = 50
						OR = {
							is_subject = no
							overlord = {
								is_part_of_hre = yes
							}
						}
						OR = {
							is_subject_of_type = march
							has_reform = imperial_march_reform # Extended Timeline
							has_reform = margrave_reform # Governments Expanded
							any_neighbor_country = {
								is_subject = no
								is_part_of_hre = no
								army_size = PREV
								total_development = PREV
							}
						}
					}
				}
			}
			set_global_flag = imperial_diet_subject_support_margraviates
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_support_electors }
				num_of_electors = 1
			}
			set_global_flag = imperial_diet_subject_support_electors
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_increased_tariffs }
			}
			set_global_flag = imperial_diet_subject_increased_tariffs
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_reduced_tariffs }
			}
			set_global_flag = imperial_diet_subject_reduced_tariffs
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_legitimation_of_expansion }
			}
			set_global_flag = imperial_diet_subject_legitimation_of_expansion
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_cut_down_noble_power }
				OR = {
					AND = {
						is_part_of_hre = yes
						has_estate = estate_nobles
					}
					any_country = {
						is_part_of_hre = yes
						has_estate = estate_nobles
					}
				}
			}
			set_global_flag = imperial_diet_subject_cut_down_noble_power
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_cut_down_clergy_power }
				OR = {
					AND = {
						is_part_of_hre = yes
						has_estate = estate_church
					}
					any_country = {
						is_part_of_hre = yes
						has_estate = estate_church
					}
				}
			}
			set_global_flag = imperial_diet_subject_cut_down_clergy_power
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_cut_down_burghers_power }
				OR = {
					AND = {
						is_part_of_hre = yes
						has_estate = estate_burghers
					}
					any_country = {
						is_part_of_hre = yes
						has_estate = estate_burghers
					}
				}
			}
			set_global_flag = imperial_diet_subject_cut_down_burghers_power
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_concessions_to_nobles }
				OR = {
					AND = {
						is_part_of_hre = yes
						has_estate = estate_nobles
					}
					any_country = {
						is_part_of_hre = yes
						has_estate = estate_nobles
					}
				}
			}
			set_global_flag = imperial_diet_subject_concessions_to_nobles
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_concessions_to_clergy }
				OR = {
					AND = {
						is_part_of_hre = yes
						has_estate = estate_church
					}
					any_country = {
						is_part_of_hre = yes
						has_estate = estate_church
					}
				}
			}
			set_global_flag = imperial_diet_subject_concessions_to_clergy
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_concessions_to_burghers }
				OR = {
					AND = {
						is_part_of_hre = yes
						has_estate = estate_burghers
					}
					any_country = {
						is_part_of_hre = yes
						has_estate = estate_burghers
					}
				}
			}
			set_global_flag = imperial_diet_subject_concessions_to_burghers
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_large_scale_investments }
			}
			set_global_flag = imperial_diet_subject_large_scale_investments
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_imperial_loans }
			}
			set_global_flag = imperial_diet_subject_imperial_loans
		}
		1 = {
			trigger = {
				has_dlc = "Mandate of Heaven"
				NOT = { has_global_flag = imperial_diet_subject_promote_prosperity }
				stability = 3
			}
			set_global_flag = imperial_diet_subject_promote_prosperity
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_seize_land_for_the_crown }
			}
			set_global_flag = imperial_diet_subject_seize_land_for_the_crown
		}
		1 = {
			trigger = {
				has_dlc = "Mare Nostrum"
				NOT = { has_global_flag = imperial_diet_subject_imperial_trade_leagues_rights }
				OR = {
					AND = {
						is_part_of_hre = yes
						is_in_trade_league = yes
					}
					any_country = {
						is_part_of_hre = yes
						is_in_trade_league = yes
					}
				}
			}
			set_global_flag = imperial_diet_subject_imperial_trade_leagues_rights
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_imperial_religion_act }
				OR = {
					AND = {
						is_part_of_hre = yes
						OR = {
							NOT = { religion = emperor }
							any_owned_province = {
								has_owner_religion = no
							}
						}
					}
					any_country = {
						is_part_of_hre = yes
						OR = {
							NOT = { religion = emperor }
							any_owned_province = {
								has_owner_religion = no
							}
						}
					}
				}
			}
			set_global_flag = imperial_diet_subject_imperial_religion_act
		}
		10 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_approved_imperial_anti_heresy_act }
				NOT = { has_global_flag = imperial_diet_approved_imperial_humanist_act }
				NOT = { has_global_flag = imperial_diet_subject_imperial_anti_heresy_act }
				OR = {
					is_religion_enabled = protestant
					is_religion_enabled = reformed
				}
				OR = {
					current_age = age_of_discovery
					current_age = age_of_reformation
					current_age = age_of_absolutism
				}
			}
			set_global_flag = imperial_diet_subject_imperial_anti_heresy_act
		}
		10 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_approved_imperial_anti_heresy_act }
				NOT = { has_global_flag = imperial_diet_approved_imperial_humanist_act }
				NOT = { has_global_flag = imperial_diet_subject_imperial_humanist_act }
				OR = {
					is_religion_enabled = protestant
					is_religion_enabled = reformed
				}
				OR = {
					current_age = age_of_discovery
					current_age = age_of_reformation
					current_age = age_of_absolutism
				}
			}
			set_global_flag = imperial_diet_subject_imperial_humanist_act
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_imperial_war_taxes }
				OR = {
					AND = {
						is_part_of_hre = yes
						any_country = {
							is_part_of_hre = no
							OR = {
								is_in_war = {
									attacker_leader = THIS
									defenders = PREV
								}
								is_in_war = {
									defender_leader = THIS
									attackers = PREV
								}
							}
						}
					}
					any_country = {
						is_part_of_hre = yes
						any_country = {
							is_part_of_hre = no
							OR = {
								is_in_war = {
									attacker_leader = THIS
									defenders = PREV
								}
								is_in_war = {
									defender_leader = THIS
									attackers = PREV
								}
							}
						}
					}
				}
			}
			set_global_flag = imperial_diet_subject_imperial_war_taxes
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_imperial_diplomacy }
			}
			set_global_flag = imperial_diet_subject_imperial_diplomacy
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_imperial_marriages }
				OR = {
					AND = {
						is_emperor = no
						is_part_of_hre = yes
						government = monarchy
						has_heir = no
						has_regency = no
						is_lesser_in_union = no
					}
					any_country = {
						is_emperor = no
						is_part_of_hre = yes
						government = monarchy
						has_heir = no
						has_regency = no
						is_lesser_in_union = no
					}
				}
			}
			set_global_flag = imperial_diet_subject_imperial_marriages
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_militarisation_regulations }
			}
			set_global_flag = imperial_diet_subject_militarisation_regulations
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_demilitarisation_regulations }
			}
			set_global_flag = imperial_diet_subject_demilitarisation_regulations
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_enforced_cultural_isolation }
			}
			set_global_flag = imperial_diet_subject_enforced_cultural_isolation
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_invest_into_civil_infrastructure }
			}
			set_global_flag = imperial_diet_subject_invest_into_civil_infrastructure
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_invest_into_military_infrastructure }
			}
			set_global_flag = imperial_diet_subject_invest_into_military_infrastructure
		}
		1 = {
			trigger = {
				NOT = { has_global_flag = imperial_diet_subject_centralise_bureaucracy }
			}
			set_global_flag = imperial_diet_subject_centralise_bureaucracy
		}
	}
}

enact_effects_of_imperial_diet = {
	if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_support_free_cities
		}
		enact_effect_of_imperial_diet_subject = { support_free_cities = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_support_margraviates
		}
		enact_effect_of_imperial_diet_subject = { support_margraviates = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_support_electors
		}
		enact_effect_of_imperial_diet_subject = { support_electors = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_increased_tariffs
		}
		enact_effect_of_imperial_diet_subject = { increased_tariffs = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_reduced_tariffs
		}
		enact_effect_of_imperial_diet_subject = { reduced_tariffs = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_legitimation_of_expansion
		}
		enact_effect_of_imperial_diet_subject = { legitimation_of_expansion = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_cut_down_noble_power
		}
		enact_effect_of_imperial_diet_subject = { cut_down_noble_power = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_cut_down_clergy_power
		}
		enact_effect_of_imperial_diet_subject = { cut_down_clergy_power = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_cut_down_burghers_power
		}
		enact_effect_of_imperial_diet_subject = { cut_down_burghers_power = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_concessions_to_nobles
		}
		enact_effect_of_imperial_diet_subject = { concessions_to_nobles = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_concessions_to_clergy
		}
		enact_effect_of_imperial_diet_subject = { concessions_to_clergy = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_concessions_to_burghers
		}
		enact_effect_of_imperial_diet_subject = { concessions_to_burghers = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_large_scale_investments
		}
		enact_effect_of_imperial_diet_subject = { large_scale_investments = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_loans
		}
		enact_effect_of_imperial_diet_subject = { imperial_loans = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_promote_prosperity
		}
		enact_effect_of_imperial_diet_subject = { promote_prosperity = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_seize_land_for_the_crown
		}
		enact_effect_of_imperial_diet_subject = { seize_land_for_the_crown = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_trade_leagues_rights
		}
		enact_effect_of_imperial_diet_subject = { imperial_trade_leagues_rights = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_religion_act
		}
		enact_effect_of_imperial_diet_subject = { imperial_religion_act = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_anti_heresy_act
		}
		enact_effect_of_imperial_diet_subject = { imperial_anti_heresy_act = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_humanist_act
		}
		enact_effect_of_imperial_diet_subject = { imperial_humanist_act = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_war_taxes
		}
		enact_effect_of_imperial_diet_subject = { imperial_war_taxes = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_diplomacy
		}
		enact_effect_of_imperial_diet_subject = { imperial_diplomacy = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_imperial_marriages
		}
		enact_effect_of_imperial_diet_subject = { imperial_marriages = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_militarisation_regulations
		}
		enact_effect_of_imperial_diet_subject = { militarisation_regulations = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_demilitarisation_regulations
		}
		enact_effect_of_imperial_diet_subject = { demilitarisation_regulations = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_enforced_cultural_isolation
		}
		enact_effect_of_imperial_diet_subject = { enforced_cultural_isolation = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_invest_into_civil_infrastructure
		}
		enact_effect_of_imperial_diet_subject = { invest_into_civil_infrastructure = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_invest_into_military_infrastructure
		}
		enact_effect_of_imperial_diet_subject = { invest_into_military_infrastructure = yes }
	}
	else_if = {
		limit = {
			has_global_flag = chosen_imperial_diet_subject_centralise_bureaucracy
		}
		enact_effect_of_imperial_diet_subject = { centralise_bureaucracy = yes }
	}
}

enact_effect_of_imperial_diet_subject = {
	[[support_free_cities]
		if = {
			limit = {
				always = $support_free_cities$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					has_reform = free_city
				}
				capital_scope = {
					hidden_effect = {
						remove_province_modifier = imperial_diet_modifier_support_free_cities
					}
					add_base_tax = 1
					add_base_production = 1
					add_base_manpower = 1
					add_province_modifier = {
						name = imperial_diet_modifier_support_free_cities
						duration = 1825
					}
				}
			}
		}
	]
	[[support_margraviates]
		if = {
			limit = {
				always = $support_margraviates$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					total_development = 50
					OR = {
						is_subject = no
						overlord = {
							is_part_of_hre = yes
						}
					}
					OR = {
						is_subject_of_type = march
						has_reform = imperial_march_reform # Extended Timeline
						has_reform = margrave_reform # Governments Expanded
						any_neighbor_country = {
							is_subject = no
							is_part_of_hre = no
							army_size = PREV
							total_development = PREV
						}
					}
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_support_margraviates
				}
				add_country_modifier = {
					name = imperial_diet_modifier_support_margraviates
					duration = 1825
				}
			}
		}
	]
	[[support_electors]
		if = {
			limit = {
				always = $support_electors$
			}
			every_elector = {
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_support_electors
				}
				add_country_modifier = {
					name = imperial_diet_modifier_support_electors
					duration = 1825
				}
			}
		}
	]
	[[increased_tariffs]
		if = {
			limit = {
				always = $increased_tariffs$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_increased_tariffs
				}
				add_mercantilism = 2
				add_country_modifier = {
					name = imperial_diet_modifier_increased_tariffs
					duration = 1825
				}
			}
		}
	]
	[[reduced_tariffs]
		if = {
			limit = {
				always = $reduced_tariffs$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_reduced_tariffs
				}
				add_country_modifier = {
					name = imperial_diet_modifier_reduced_tariffs
					duration = 1825
				}
			}
		}
	]
	[[legitimation_of_expansion]
		if = {
			limit = {
				always = $legitimation_of_expansion$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_legitimation_of_expansion
				}
				add_country_modifier = {
					name = imperial_diet_modifier_legitimation_of_expansion
					duration = 1825
				}
			}
		}
	]
	[[cut_down_noble_power]
		if = {
			limit = {
				always = $cut_down_noble_power$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					has_estate = estate_nobles
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_cut_down_noble_power
				}
				add_estate_loyalty = {
					estate = estate_nobles
					loyalty = -5
				}
				add_country_modifier = {
					name = imperial_diet_modifier_cut_down_noble_power
					duration = 1825
				}
			}
		}
	]
	[[cut_down_clergy_power]
		if = {
			limit = {
				always = $cut_down_clergy_power$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					has_estate = estate_church
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_cut_down_clergy_power
				}
				add_estate_loyalty = {
					estate = estate_church
					loyalty = -5
				}
				add_country_modifier = {
					name = imperial_diet_modifier_cut_down_clergy_power
					duration = 1825
				}
			}
		}
	]
	[[cut_down_burghers_power]
		if = {
			limit = {
				always = $cut_down_burghers_power$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					has_estate = estate_burghers
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_cut_down_burghers_power
				}
				add_estate_loyalty = {
					estate = estate_burghers
					loyalty = -5
				}
				add_country_modifier = {
					name = imperial_diet_modifier_cut_down_burghers_power
					duration = 1825
				}
			}
		}
	]
	[[concessions_to_nobles]
		if = {
			limit = {
				always = $concessions_to_nobles$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					has_estate = estate_nobles
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_concessions_to_nobles
				}
				change_estate_land_share = {
					estate = estate_nobles
					share = 5
				}
				add_estate_loyalty = {
					estate = estate_nobles
					loyalty = 10
				}
				add_country_modifier = {
					name = imperial_diet_modifier_concessions_to_nobles
					duration = 1825
				}
			}
		}
	]
	[[concessions_to_clergy]
		if = {
			limit = {
				always = $concessions_to_clergy$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					has_estate = estate_church
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_concessions_to_clergy
				}
				change_estate_land_share = {
					estate = estate_church
					share = 5
				}
				add_estate_loyalty = {
					estate = estate_church
					loyalty = 10
				}
				add_country_modifier = {
					name = imperial_diet_modifier_concessions_to_clergy
					duration = 1825
				}
			}
		}
	]
	[[concessions_to_burghers]
		if = {
			limit = {
				always = $concessions_to_burghers$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					has_estate = estate_burghers
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_concessions_to_burghers
				}
				change_estate_land_share = {
					estate = estate_burghers
					share = 5
				}
				add_estate_loyalty = {
					estate = estate_burghers
					loyalty = 10
				}
				add_country_modifier = {
					name = imperial_diet_modifier_concessions_to_burghers
					duration = 1825
				}
			}
		}
	]
	[[large_scale_investments]
		if = {
			limit = {
				always = $large_scale_investments$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_large_scale_investments
				}
				add_country_modifier = {
					name = imperial_diet_modifier_large_scale_investments
					duration = 1825
				}
			}
		}
	]
	[[imperial_loans]
		if = {
			limit = {
				always = $imperial_loans$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_imperial_loans
				}
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_loans
					duration = 1825
				}
			}
		}
	]
	[[promote_prosperity]
		if = {
			limit = {
				always = $promote_prosperity$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				add_years_of_income = -0.5
				capital_scope = {
					add_prosperity = 50
				}
			}
		}
	]
	[[seize_land_for_the_crown]
		if = {
			limit = {
				always = $seize_land_for_the_crown$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				add_estate_loyalty = {
					estate = all
					loyalty = -10
					short = yes
				}
				custom_tooltip = add_5_crown_land_share
				hidden_effect = {
					change_estate_land_share = {
						estate = all
						share = -5
					}
				}
			}
		}
	]
	[[imperial_trade_leagues_rights]
		if = {
			limit = {
				always = $imperial_trade_leagues_rights$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					is_in_trade_league = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_imperial_trade_leagues_rights
				}
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_trade_leagues_rights
					duration = 1825
				}
			}
		}
	]
	[[imperial_religion_act]
		if = {
			limit = {
				always = $imperial_religion_act$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					OR = {
						NOT = { religion = emperor }
						any_owned_province = {
							has_owner_religion = no
						}
					}
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_imperial_religion_act
				}
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_religion_act
					duration = 3650
				}
			}
		}
	]
	[[imperial_anti_heresy_act]
		if = {
			limit = {
				always = $imperial_anti_heresy_act$
			}
			every_country = {
				limit = {
					OR = {
						is_emperor = yes
						AND = {
							is_part_of_hre = yes
							emperor = { religion = PREV }
						}
					}
				}
				hidden_effect = {
					set_global_flag = imperial_diet_approved_imperial_anti_heresy_act
					remove_country_modifier = imperial_diet_modifier_imperial_anti_heresy_act
				}
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_anti_heresy_act
					duration = -1
				}
			}
		}
	]
	[[imperial_humanist_act]
		if = {
			limit = {
				always = $imperial_humanist_act$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					set_global_flag = imperial_diet_approved_imperial_humanist_act
					remove_country_modifier = imperial_diet_modifier_imperial_humanist_act
				}
				add_stability = 1
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_humanist_act
					duration = -1
				}
			}
		}
	]
	[[imperial_war_taxes]
		if = {
			limit = {
				always = $imperial_war_taxes$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					NOT = {
						any_country = {
							is_part_of_hre = no
							OR = {
								is_in_war = {
									attacker_leader = THIS
									defenders = PREV
								}
								is_in_war = {
									defender_leader = THIS
									attackers = PREV
								}
							}
						}
					}
				}
				add_years_of_income = -0.1
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
					any_country = {
						is_part_of_hre = no
						OR = {
							is_in_war = {
								attacker_leader = THIS
								defenders = PREV
							}
							is_in_war = {
								defender_leader = THIS
								attackers = PREV
							}
						}
					}
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_imperial_war_taxes
				}
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_war_taxes
					duration = 730
				}
			}
		}
	]
	[[imperial_diplomacy]
		if = {
			limit = {
				always = $imperial_diplomacy$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_imperial_diplomacy
				}
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_diplomacy
					duration = 1095
				}
			}
		}
	]
	[[imperial_marriages]
		if = {
			limit = {
				always = $imperial_marriages$
			}
			every_country = {
				limit = {
					is_emperor = no
					is_part_of_hre = yes
					government = monarchy
					has_heir = no
					has_regency = no
					is_lesser_in_union = no
				}
				add_legitimacy = -10
				random_list = {
					33 = {
						custom_tooltip = imperial_diet_gain_heir_from_emperor_dynasty
					}
					33 = {
						trigger = {
							has_dlc = "Rights of Man"
							has_consort = no
						}
						custom_tooltip = imperial_diet_gain_consort_from_emperor_dynasty
					}
					33 = {
						# No Effect
					}
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_imperial_marriages
					country_event = { id = besseres_hrr_imperial_diet_events.6 }
				}
				add_country_modifier = {
					name = imperial_diet_modifier_imperial_marriages
					duration = 3650
				}
			}
		}
	]
	[[militarisation_regulations]
		if = {
			limit = {
				always = $militarisation_regulations$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_militarisation_regulations
				}
				add_country_modifier = {
					name = imperial_diet_modifier_militarisation_regulations
					duration = 3650
				}
			}
		}
	]
	[[demilitarisation_regulations]
		if = {
			limit = {
				always = $demilitarisation_regulations$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_demilitarisation_regulations
				}
				add_country_modifier = {
					name = imperial_diet_modifier_demilitarisation_regulations
					duration = 1825
				}
			}
		}
	]
	[[enforced_cultural_isolation]
		if = {
			limit = {
				always = $enforced_cultural_isolation$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_enforced_cultural_isolation
					every_owned_province = {
						limit = {
							has_owner_culture = yes
						}
						remove_province_modifier = imperial_diet_province_modifier_enforced_cultural_isolation
						add_province_modifier = {
							name = imperial_diet_province_modifier_enforced_cultural_isolation
							duration = 2920
						}
					}
				}
				add_country_modifier = {
					name = imperial_diet_modifier_enforced_cultural_isolation
					duration = 2920
				}
				custom_tooltip = every_owned_province_with_primary_culture_tt
				tooltip = {
					add_province_modifier = {
						name = imperial_diet_province_modifier_enforced_cultural_isolation
						duration = 2920
					}
				}
			}
		}
	]
	[[invest_into_civil_infrastructure]
		if = {
			limit = {
				always = $invest_into_civil_infrastructure$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_invest_into_civil_infrastructure
				}
				add_country_modifier = {
					name = imperial_diet_modifier_invest_into_civil_infrastructure
					duration = 1825
				}
			}
		}
	]
	[[invest_into_military_infrastructure]
		if = {
			limit = {
				always = $invest_into_military_infrastructure$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_invest_into_military_infrastructure
				}
				add_country_modifier = {
					name = imperial_diet_modifier_invest_into_military_infrastructure
					duration = 1825
				}
			}
		}
	]
	[[centralise_bureaucracy]
		if = {
			limit = {
				always = $centralise_bureaucracy$
			}
			every_country = {
				limit = {
					is_part_of_hre = yes
				}
				hidden_effect = {
					remove_country_modifier = imperial_diet_modifier_centralise_bureaucracy
				}
				add_country_modifier = {
					name = imperial_diet_modifier_centralise_bureaucracy
					duration = 1825
				}
			}
		}
	]
}

select_imperial_diet_subject = {
	custom_tooltip = select_imperial_diet_subject_tt
	[[tooltip]
		if = {
			limit = {
				always = $tooltip$
			}
			custom_tooltip = select_imperial_diet_subject_effects_tt
			tooltip = {
				enact_effect_of_imperial_diet_subject = { $subject$ = yes }
			}
		}
	]
	hidden_effect = {
		set_global_flag = chosen_imperial_diet_subject_$subject$
		REB = {
			set_variable = { imperial_diet_yes_votes = 1 }
			set_variable = { imperial_diet_no_votes = 0 }
		}
		set_country_flag = imperial_diet_voted
		set_country_flag = imperial_diet_voted_yes
		every_country = {
			limit = {
				NOT = { tag = PREV }
				OR = {
					is_part_of_hre = yes
					is_elector = yes
					is_emperor = yes
				}
			}
			country_event = { id = besseres_hrr_imperial_diet_events.2 }
		}
	}
}

clear_possible_imperial_diet_subjects = {
	hidden_effect = {
		clr_global_flag = imperial_diet_subject_support_free_cities
		clr_global_flag = chosen_imperial_diet_subject_support_free_cities
		clr_global_flag = imperial_diet_subject_support_margraviates
		clr_global_flag = chosen_imperial_diet_subject_support_margraviates
		clr_global_flag = imperial_diet_subject_support_electors
		clr_global_flag = chosen_imperial_diet_subject_support_electors
		clr_global_flag = imperial_diet_subject_increased_tariffs
		clr_global_flag = chosen_imperial_diet_subject_increased_tariffs
		clr_global_flag = imperial_diet_subject_reduced_tariffs
		clr_global_flag = chosen_imperial_diet_subject_reduced_tariffs
		clr_global_flag = imperial_diet_subject_legitimation_of_expansion
		clr_global_flag = chosen_imperial_diet_subject_legitimation_of_expansion
		clr_global_flag = imperial_diet_subject_cut_down_noble_power
		clr_global_flag = chosen_imperial_diet_subject_cut_down_noble_power
		clr_global_flag = imperial_diet_subject_cut_down_clergy_power
		clr_global_flag = chosen_imperial_diet_subject_cut_down_clergy_power
		clr_global_flag = imperial_diet_subject_cut_down_burghers_power
		clr_global_flag = chosen_imperial_diet_subject_cut_down_burghers_power
		clr_global_flag = imperial_diet_subject_concessions_to_nobles
		clr_global_flag = chosen_imperial_diet_subject_concessions_to_nobles
		clr_global_flag = imperial_diet_subject_concessions_to_clergy
		clr_global_flag = chosen_imperial_diet_subject_concessions_to_clergy
		clr_global_flag = imperial_diet_subject_concessions_to_burghers
		clr_global_flag = chosen_imperial_diet_subject_concessions_to_burghers
		clr_global_flag = imperial_diet_subject_large_scale_investments
		clr_global_flag = chosen_imperial_diet_subject_large_scale_investments
		clr_global_flag = imperial_diet_subject_imperial_loans
		clr_global_flag = chosen_imperial_diet_subject_imperial_loans
		clr_global_flag = imperial_diet_subject_promote_prosperity
		clr_global_flag = chosen_imperial_diet_subject_promote_prosperity
		clr_global_flag = imperial_diet_subject_seize_land_for_the_crown
		clr_global_flag = chosen_imperial_diet_subject_seize_land_for_the_crown
		clr_global_flag = imperial_diet_subject_imperial_trade_leagues_rights
		clr_global_flag = chosen_imperial_diet_subject_imperial_trade_leagues_rights
		clr_global_flag = imperial_diet_subject_imperial_religion_act
		clr_global_flag = chosen_imperial_diet_subject_imperial_religion_act
		clr_global_flag = imperial_diet_subject_imperial_anti_heresy_act
		clr_global_flag = chosen_imperial_diet_subject_imperial_anti_heresy_act
		clr_global_flag = imperial_diet_subject_imperial_humanist_act
		clr_global_flag = chosen_imperial_diet_subject_imperial_humanist_act
		clr_global_flag = imperial_diet_subject_imperial_war_taxes
		clr_global_flag = chosen_imperial_diet_subject_imperial_war_taxes
		clr_global_flag = imperial_diet_subject_imperial_diplomacy
		clr_global_flag = chosen_imperial_diet_subject_imperial_diplomacy
		clr_global_flag = imperial_diet_subject_imperial_marriages
		clr_global_flag = chosen_imperial_diet_subject_imperial_marriages
		clr_global_flag = imperial_diet_subject_militarisation_regulations
		clr_global_flag = chosen_imperial_diet_subject_militarisation_regulations
		clr_global_flag = imperial_diet_subject_demilitarisation_regulations
		clr_global_flag = chosen_imperial_diet_subject_demilitarisation_regulations
		clr_global_flag = imperial_diet_subject_enforced_cultural_isolation
		clr_global_flag = chosen_imperial_diet_subject_enforced_cultural_isolation
		clr_global_flag = imperial_diet_subject_invest_into_civil_infrastructure
		clr_global_flag = chosen_imperial_diet_subject_invest_into_civil_infrastructure
		clr_global_flag = imperial_diet_subject_invest_into_military_infrastructure
		clr_global_flag = chosen_imperial_diet_subject_invest_into_military_infrastructure
		clr_global_flag = imperial_diet_subject_centralise_bureaucracy
		clr_global_flag = chosen_imperial_diet_subject_centralise_bureaucracy
	}
}

clear_up_imperial_diet_effect = {
	clear_possible_imperial_diet_subjects = yes
	hidden_effect = {
		REB = {
			set_variable = { imperial_diet_yes_votes = 0 }
			set_variable = { imperial_diet_no_votes = 0 }
		}
		every_country = {
			clr_country_flag = imperial_diet_voted
			clr_country_flag = imperial_diet_voted_yes
			clr_country_flag = imperial_diet_voted_no
		}
		clr_global_flag = imperial_diet_active
		clr_global_flag = recently_had_imperial_diet
		set_global_flag = recently_had_imperial_diet
		clear_global_event_target = imperial_diet_organiser
		clear_global_event_target = imperial_diet_place
	}
}

vote_in_imperial_diet = {
	custom_tooltip = vote_in_imperial_diet_tt_$vote$
	hidden_effect = {
		set_country_flag = imperial_diet_voted
		set_country_flag = imperial_diet_voted_$vote$
		REB = {
			if = {
				limit = {
					always = $vote$
				}
				change_variable = { imperial_diet_yes_votes = 1 }
			}
			else = {
				change_variable = { imperial_diet_no_votes = 1 }
			}
		}
		if = {
			limit = {
				always = $vote$
			}
			event_target:imperial_diet_organiser = {
				add_opinion = {
					who = ROOT
					modifier = imperial_diet_support_opinion
				}
			}
		}
		else = {
			event_target:imperial_diet_organiser = {
				add_opinion = {
					who = ROOT
					modifier = imperial_diet_opposition_opinion
				}
			}
		}
	}
}