scripted_gui = {
	show_their_ideas_window = {
		context_type = selected_country_context

		window_name = "show_their_ideas_window"
		parent_window_token = selected_country_view_diplomacy

		visible = {
			ROOT = {
				is_ai = no
			}
		}
	}

	open_ideas_window = {
		context_type = player_context

		window_name = "open_ideas_window"
		parent_window_token = politics_tab

		visible = {
			always = yes
		}

		effects = {
			open_button_click = {
				if = {
					limit = {
						has_variable = show_ideas_window
					}
					clear_variable = show_ideas_window
				}
				else = {
					set_ideas_up_at_start_effect = yes
					clear_variable = show_selectable_idea_groups_window
					clear_variable = show_ideas_window_confirm_alert
					clear_variable = confirm_idea_group
					clear_variable = confirm_idea
					clear_variable = show_policies_window
					remove_flags_for_available_dismissed_alerts = yes
					refresh_eu4_like_alerts = yes
					set_variable = { show_ideas_window = 1 }
				}
			}
		}

		triggers = {
			open_button_glow_visible = {
				OR = {
					can_select_any_idea_group = yes
					can_select_any_idea = yes
				}
			}
		}

		properties = {
			open_button_glow = {
				x = eu4_style_ideas_open_button_x
			}
			open_button = {
				x = eu4_style_ideas_open_button_x
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 168
		ai_test_variance = 1

		ai_check = {
			NOT = { has_variable = show_ideas_window }
			NOT = { has_variable = show_selectable_idea_groups_window }
			OR = {
				AND = {
					can_select_any_idea_group = yes
					OR = {
						NOT = { has_country_flag = does_not_want_to_choose_idea_group }
						has_country_flag = {
							flag = does_not_want_to_choose_idea_group
							days > 50
						}
					}
				}
				can_select_any_idea = yes
				AI_can_remove_any_idea_group = yes
				can_select_any_policy = yes
				AI_might_want_to_remove_any_policy = yes
				# Never opened the GUI & has never set up ideas:
				NOT = { has_country_flag = selected_idea_groups_array_set }
				check_variable = { national_ideas_id = 0 }
			}
		}

		ai_weights = {
			open_button_click = {
				ai_will_do = {
					base = 1

					modifier = {
						factor = 0
						has_variable = show_ideas_window
					}
					modifier = {
						factor = 0
						has_global_flag = eu4_like_ideas_ai_disabled
					}
					modifier = {
						factor = 0
						NOT = {
							OR = {
								AND = {
									NOT = { has_global_flag = eu4_like_ideas_ai_only_majors }
									NOT = { has_global_flag = eu4_like_ideas_ai_only_minors }
									OR = {
										NOT = { has_global_flag = eu4_like_ideas_ai_idea_usage_delayed }
										AND = {
											has_global_flag = eu4_like_ideas_ai_idea_usage_delayed
											meta_trigger = {
												text = {
													date > [DATE]
												}
												DATE = "[?global.eu4_like_ideas_AI_idea_usage_delay.GetDateStringNoHour]"
											}
										}
									}
								}
								AND = {
									is_major = yes
									has_global_flag = eu4_like_ideas_ai_only_majors
									OR = {
										NOT = { has_global_flag = eu4_like_ideas_ai_idea_usage_delayed }
										AND = {
											has_global_flag = eu4_like_ideas_ai_idea_usage_delayed
											meta_trigger = {
												text = {
													date > [DATE]
												}
												DATE = "[?global.eu4_like_ideas_AI_idea_usage_delay.GetDateStringNoHour]"
											}
										}
									}
								}
								AND = {
									is_major = no
									has_global_flag = eu4_like_ideas_ai_only_minors
									OR = {
										NOT = { has_global_flag = eu4_like_ideas_ai_idea_usage_delayed }
										AND = {
											has_global_flag = eu4_like_ideas_ai_idea_usage_delayed
											meta_trigger = {
												text = {
													date > [DATE]
												}
												DATE = "[?global.eu4_like_ideas_AI_idea_usage_delay.GetDateStringNoHour]"
											}
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	ideas_window = {
		context_type = player_context

		window_name = "ideas_window"

		dirty = show_ideas_window

		visible = {
			has_variable = show_ideas_window
		}

		effects = {
			close_button_click = {
				clear_variable = show_ideas_window
			}
			flag_click = {
				capital_scope = {
					ROOT = {
						goto_state = PREV
					}
				}
				update_main_ideas_window = yes
			}
			add_policy_button_click = {
				set_variable = { show_policies_window = 1 }
				update_policies_effect = yes
				clear_variable = show_ideas_window
			}
			show_remaining_idea_groups_button_click = {
				set_variable = { show_selectable_idea_groups_window = 1 }
				clear_variable = show_ideas_window
			}

			remove_policy_button_click = {
				if = {
					limit = {
						meta_trigger = {
							text = {
								set_temp_variable = { required_date_to_remove_policy = eu4_like_policy_[POLICY]_date }
							}
							POLICY = "[?v]"
						}
						meta_trigger = {
							text = {
								date > [DATE]
							}
							DATE = "[?required_date_to_remove_policy.GetDateStringNoHour]"
						}
					}
					if = {
						limit = {
							is_ai = no
						}
						set_variable = { show_ideas_window_confirm_alert = 5 }
						set_variable = { confirm_policy = v }
					}
					else = {
						remove_policy = yes
					}
				}
				update_main_ideas_window = yes
			}

			open_selectable_ideas_button_click = {
				set_variable = { show_selectable_idea_groups_window = 1 }
				clear_variable = show_ideas_window
			}
			remove_idea_group_button_click = {
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 3 }
					set_variable = { confirm_idea_group = v }
				}
				else = {
					remove_idea_group_effect = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_1_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 1 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_1_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_2_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 2 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_2_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_3_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 3 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_3_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_4_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 4 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_4_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_5_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 5 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_5_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_6_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 6 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_6_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
			select_idea_button_7_click = {
				update_idea_cost_modifiers = yes
				update_policy_costs = yes
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 2 }
					set_variable = { confirm_idea_group = v }
					set_variable = { confirm_idea = 7 }
				}
				else = {
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					complete_7_idea_of_group = yes
				}
				update_main_ideas_window = yes
			}
		}

		triggers = {
			close_button_click_enabled = {
				NOT = { has_variable = show_ideas_window_confirm_alert }
			}
			add_policy_button_click_enabled = {
				OR = {
					has_not_selected_max_amount_of_policies = yes
					is_ai = no
				}
			}
			show_remaining_idea_groups_button_visible = {
				NOT = { is_in_array = { selected_idea_groups = 0 } }
			}
			traditions_icon_1_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_0
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			traditions_icon_2_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_0
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			traditions_text_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_0
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			ambitions_icon_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_8
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			ambitions_text_visible = {
				is_ai = no
				meta_trigger = {
					text = {
						has_idea = national_ideas_[GROUP]_8
					}
					GROUP = "[?national_ideas_id]"
				}
			}
			national_idea_progress_green_visible = {
				check_variable = { completed_national_ideas < 7 }
				check_variable = { national_ideas_progress > 0 }
			}
			national_idea_progress_black_visible = {
				check_variable = { completed_national_ideas < 7 }
			}
			national_idea_progress_frame_visible = {
				check_variable = { completed_national_ideas < 7 }
			}
			national_idea_1_click_enabled = {
				check_variable = { completed_national_ideas > 0 }
			}
			national_idea_2_click_enabled = {
				check_variable = { completed_national_ideas > 1 }
			}
			national_idea_3_click_enabled = {
				check_variable = { completed_national_ideas > 2 }
			}
			national_idea_4_click_enabled = {
				check_variable = { completed_national_ideas > 3 }
			}
			national_idea_5_click_enabled = {
				check_variable = { completed_national_ideas > 4 }
			}
			national_idea_6_click_enabled = {
				check_variable = { completed_national_ideas > 5 }
			}
			national_idea_7_click_enabled = {
				check_variable = { completed_national_ideas > 6 }
			}

			open_selectable_ideas_button_visible = {
				check_variable = { v = 0 }
			}
			open_selectable_ideas_button_click_enabled = {
				OR = {
					has_global_flag = eu4_like_ideas_test_flag
					check_variable = { i = 0 }
					AND = {
						check_variable = { global.num_of_unlockable_idea_groups > i }
						set_temp_variable = { idea_slot_index_plus_1 = i }
						add_to_temp_variable = { idea_slot_index_plus_1 = 1 }
						set_temp_variable = { idea_slot_index_minus_1 = i }
						subtract_from_temp_variable = { idea_slot_index_minus_1 = 1 }
						meta_trigger = {
							text = {
								set_temp_variable = { idea_slot_unlock_date = global.unlock_date_for_idea_group_[SLOT] }
							}
							SLOT = "[?idea_slot_index_plus_1]"
						}
						OR = {
							meta_trigger = {
								text = {
									date > [DATE]
								}
								DATE = "[?idea_slot_unlock_date.GetDateStringNoHour]"
							}
							NOT = { check_variable = { selected_idea_groups^idea_slot_index_minus_1 = 0 } }
						}
					}
				}
			}
			free_slot_glow_visible = {
				is_ai = no
				check_variable = { v = 0 }
				specific_idea_group_slot_is_unlocked = yes
			}
			text_unlocked_at_visible = {
				check_variable = { v = 0 }
			}
			selected_idea_groups_bg_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_resource_icon_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_icon_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_name_visible = {
				check_variable = { v > 0 }
			}
			remove_idea_group_button_visible = {
				check_variable = { v > 0 }
			}
			selected_idea_uncompleted_icon_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
			selected_idea_completed_icon_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 6 }
					}
					GROUP = "[?v]"
				}
			}

			cannot_select_idea_1_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 0 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_1_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 0 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_1_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 0 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_1_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 1 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_1_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 0 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_2_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 1 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_2_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 1 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_2_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 1 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_2_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 2 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_2_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 1 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_3_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 2 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_3_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 2 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_3_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 2 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_3_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 3 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_3_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 2 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_4_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 3 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_4_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 3 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_4_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 3 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_4_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 4 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_4_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 3 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_5_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 4 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_5_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 4 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_5_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 4 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_5_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 5 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_5_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 4 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_6_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 5 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_6_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 5 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_6_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 5 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_6_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 6 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_6_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 5 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}

			cannot_select_idea_7_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 6 }
					}
					GROUP = "[?v]"
				}
				has_political_power < idea_cost_var
			}
			can_select_idea_7_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 6 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			selected_idea_icon_7_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] > 6 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_7_visible = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
			select_idea_button_7_click_enabled = {
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] = 6 }
					}
					GROUP = "[?v]"
				}
				NOT = { has_political_power < idea_cost_var }
			}
			next_idea_progress_frame_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
			next_idea_progress_green_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
				set_temp_variable = { idea_group_progress = political_power }
				divide_temp_variable = { idea_group_progress = idea_cost_var }
				multiply_temp_variable = { idea_group_progress = 100 }
				round_temp_variable = idea_group_progress
				clamp_temp_variable = {
					var = idea_group_progress
					min = 0
					max = 100
				}
				check_variable = { idea_group_progress > 0 }
			}
			next_idea_progress_red_visible = {
				is_ai = no
				check_variable = { v > 0 }
				meta_trigger = {
					text = {
						check_variable = { completed_ideas_of_group_[GROUP] < 7 }
					}
					GROUP = "[?v]"
				}
			}
		}

		dynamic_lists = {
			selected_idea_groups_gridbox = {
				array = selected_idea_groups
				entry_container = selected_idea_groups_entry

				ai_weights = {
					open_selectable_ideas_button_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 10

								check_variable = { v = 0 }
								specific_idea_group_slot_is_unlocked = yes
							}
							modifier = {
								factor = 0
								has_country_flag = does_not_want_to_choose_idea_group
								has_country_flag = {
									flag = does_not_want_to_choose_idea_group
									days < 50
								}
							}
							modifier = {
								factor = 0
								NOT = { can_select_any_idea_group = yes }
							}
						}
					}
					select_idea_button_1_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_2_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_3_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_4_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_5_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_6_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					select_idea_button_7_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 5
								has_political_power > idea_cost_var
								NOT = { AI_might_want_to_spend_pp_on_something_else = yes }
							}
						}
					}
					remove_idea_group_button_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 2
								NOT = { has_global_flag = eu4_like_ideas_rule_AI_ability_to_remove_idea_groups_disabled }
								set_temp_variable = { ai_chance_temp = 0 }
								meta_trigger = {
									text = {
										set_temp_variable = { ai_chance_temp = mtth:ai_chance_for_selecting_idea_group_[IDEA_GROUP] }
									}
									IDEA_GROUP = "[?v]"
								}
								NOT = { check_variable = { ai_chance_temp > 0 } }
							}
						}
					}
				}
			}
			selected_policies_gridbox = {
				array = selected_policies_array
				entry_container = selected_policies_entry

				ai_weights = {
					remove_policy_button_click = {
						ai_will_do = {
							base = 0

							modifier = {
								add = 3
								AI_might_want_to_remove_any_policy = yes
								meta_trigger = {
									text = {
										set_temp_variable = { required_date_to_remove_policy = eu4_like_policy_[POLICY]_date }
									}
									POLICY = "[?v]"
								}
								meta_trigger = {
									text = {
										date > [DATE]
									}
									DATE = "[?required_date_to_remove_policy.GetDateStringNoHour]"
								}
							}
						}
					}
				}
			}
		}

		properties = {
			flag = {
				image = "[This.GetFlag]"
			}
			national_idea_progress_green = {
				frame = national_ideas_progress
			}
			selected_idea_icon = {
				image = "[This.GetIdeaGroupIcon]"
			}
			next_idea_progress_green = {
				frame = idea_group_progress
			}

			traditions_icon_1 = {
				image = "[This.GetNationalIdeaFirstPicture0]"
			}
			traditions_icon_2 = {
				image = "[This.GetNationalIdeaSecondPicture0]"
			}
			ambitions_icon = {
				image = "[This.GetNationalIdeaPicture8]"
			}
			national_idea_1 = {
				image = "[This.GetNationalIdeaPicture1]"
			}
			national_idea_2 = {
				image = "[This.GetNationalIdeaPicture2]"
			}
			national_idea_3 = {
				image = "[This.GetNationalIdeaPicture3]"
			}
			national_idea_4 = {
				image = "[This.GetNationalIdeaPicture4]"
			}
			national_idea_5 = {
				image = "[This.GetNationalIdeaPicture5]"
			}
			national_idea_6 = {
				image = "[This.GetNationalIdeaPicture6]"
			}
			national_idea_7 = {
				image = "[This.GetNationalIdeaPicture7]"
			}

			selected_idea_resource_icon = {
				image = "[This.GetIdeaGroupResourceIcon]"
			}
			select_idea_button_1 = {
				image = "[This.GetIdeaPicture1]"
			}
			selected_idea_icon_1 = {
				image = "[This.GetIdeaPicture1]"
			}
			select_idea_button_2 = {
				image = "[This.GetIdeaPicture2]"
			}
			selected_idea_icon_2 = {
				image = "[This.GetIdeaPicture2]"
			}
			select_idea_button_3 = {
				image = "[This.GetIdeaPicture3]"
			}
			selected_idea_icon_3 = {
				image = "[This.GetIdeaPicture3]"
			}
			select_idea_button_4 = {
				image = "[This.GetIdeaPicture4]"
			}
			selected_idea_icon_4 = {
				image = "[This.GetIdeaPicture4]"
			}
			select_idea_button_5 = {
				image = "[This.GetIdeaPicture5]"
			}
			selected_idea_icon_5 = {
				image = "[This.GetIdeaPicture5]"
			}
			select_idea_button_6 = {
				image = "[This.GetIdeaPicture6]"
			}
			selected_idea_icon_6 = {
				image = "[This.GetIdeaPicture6]"
			}
			select_idea_button_7 = {
				image = "[This.GetIdeaPicture7]"
			}
			selected_idea_icon_7 = {
				image = "[This.GetIdeaPicture7]"
			}

			remove_policy_button = {
				image = "[This.GetPolicyPicture]"
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 48
		ai_test_variance = 1

		ai_check = {
			has_variable = show_ideas_window
			NOT = { has_variable = show_ideas_window_confirm_alert }
		}

		ai_max_weight_taken_per_test = 5
		ai_weights = {
			close_button_click = {
				ai_will_do = {
					base = 0

					modifier = {
						add = 1
						NOT = { can_select_any_idea_group = yes }
						NOT = { can_select_any_idea = yes }
						NOT = { AI_can_remove_any_idea_group = yes }
						NOT = { can_select_any_policy = yes }
						NOT = { AI_might_want_to_remove_any_policy = yes }
					}
					modifier = {
						add = 1000
						NOT = { can_select_any_idea = yes }
						NOT = { AI_can_remove_any_idea_group = yes }
						NOT = { can_select_any_policy = yes }
						NOT = { AI_might_want_to_remove_any_policy = yes }
						has_country_flag = does_not_want_to_choose_idea_group
						has_country_flag = {
							flag = does_not_want_to_choose_idea_group
							days < 50
						}
					}
				}
			}
			flag_click = {
				ai_will_do = {
					factor = 0
				}
			}
			add_policy_button_click = {
				ai_will_do = {
					base = 0

					modifier = {
						add = 3
						can_select_any_policy = yes
					}
				}
			}
		}
	}

	selectable_idea_groups_window = {
		context_type = player_context

		window_name = "selectable_idea_groups_window"

		dirty = show_selectable_idea_groups_window

		visible = {
			has_variable = show_selectable_idea_groups_window
		}

		effects = {
			close_button_click = {
				set_variable = { show_ideas_window = 1 }
				clear_variable = show_selectable_idea_groups_window
				if = {
					limit = {
						is_ai = yes
					}
					clr_country_flag = does_not_want_to_choose_idea_group
					set_country_flag = does_not_want_to_choose_idea_group
				}
			}
			select_idea_group_button_click = {
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 1 }
					set_variable = { confirm_idea_group = v }
				}
				else = {
					select_idea_group_effect = yes
				}
				update_selectable_idea_groups_window = yes
			}
		}

		triggers = {
			close_button_click_enabled = {
				NOT = { has_variable = show_ideas_window_confirm_alert }
			}
			adm_idea_groups_empty_info_visible = {
				all_of = {
					array = global.adm_idea_groups
					value = value_temp
					index = index_temp
					set_temp_variable = { idea_group_out_of_context = value_temp }
					has_selected_idea_group = yes
				}
			}
			dip_idea_groups_empty_info_visible = {
				all_of = {
					array = global.dip_idea_groups
					value = value_temp
					index = index_temp
					set_temp_variable = { idea_group_out_of_context = value_temp }
					has_selected_idea_group = yes
				}
			}
			mil_idea_groups_empty_info_visible = {
				all_of = {
					array = global.mil_idea_groups
					value = value_temp
					index = index_temp
					set_temp_variable = { idea_group_out_of_context = value_temp }
					has_selected_idea_group = yes
				}
			}

			select_idea_group_button_click_enabled = {
				can_select_any_idea_group = yes
				set_temp_variable = { idea_group_out_of_context = v }
				NOT = { has_selected_idea_group = yes }
				set_temp_variable = { num_of_selected_adm = 0 }
				all_of = {
					array = global.adm_idea_groups
					value = value_temp
					index = index_temp
					set_temp_variable = { idea_group_out_of_context = value_temp }
					if = {
						limit = {
							has_selected_idea_group = yes
						}
						add_to_temp_variable = { num_of_selected_adm = 1 }
					}
				}
				set_temp_variable = { num_of_selected_dip = 0 }
				all_of = {
					array = global.dip_idea_groups
					value = value_temp
					index = index_temp
					set_temp_variable = { idea_group_out_of_context = value_temp }
					if = {
						limit = {
							has_selected_idea_group = yes
						}
						add_to_temp_variable = { num_of_selected_dip = 1 }
					}
				}
				set_temp_variable = { num_of_selected_mil = 0 }
				all_of = {
					array = global.mil_idea_groups
					value = value_temp
					index = index_temp
					set_temp_variable = { idea_group_out_of_context = value_temp }
					if = {
						limit = {
							has_selected_idea_group = yes
						}
						add_to_temp_variable = { num_of_selected_mil = 1 }
					}
				}
				set_temp_variable = { total_num_of_selected_ideas = num_of_selected_adm }
				add_to_temp_variable = { total_num_of_selected_ideas = num_of_selected_dip }
				add_to_temp_variable = { total_num_of_selected_ideas = num_of_selected_mil }
				divide_temp_variable = { total_num_of_selected_ideas = 2 }
				OR = {
					has_global_flag = eu4_like_ideas_test_flag
					has_global_flag = eu4_like_ideas_limit_for_idea_groups_from_same_type_disabled
					AND = {
						is_in_array = { global.adm_idea_groups = v }
						OR = {
							check_variable = { num_of_selected_adm = 0 }
							check_variable = { var = total_num_of_selected_ideas value = num_of_selected_adm compare = greater_than_or_equals }
						}
					}
					AND = {
						is_in_array = { global.dip_idea_groups = v }
						OR = {
							check_variable = { num_of_selected_dip = 0 }
							check_variable = { var = total_num_of_selected_ideas value = num_of_selected_dip compare = greater_than_or_equals }
						}
					}
					AND = {
						is_in_array = { global.mil_idea_groups = v }
						OR = {
							check_variable = { num_of_selected_mil = 0 }
							check_variable = { var = total_num_of_selected_ideas value = num_of_selected_mil compare = greater_than_or_equals }
						}
					}
				}
			}
		}

		dynamic_lists = {
			adm_idea_groups_gridbox = {
				array = global.adm_idea_groups
				entry_container = "[This.GetEu4StyleIdeasSelectableIdeaGroupEntryWindow]"

				ai_weights = {
					select_idea_group_button_click = {
						ai_will_do = {
							base = 0
							modifier = {
								set_temp_variable = { ai_chance_temp = 0 }
								meta_trigger = {
									text = {
										set_temp_variable = { ai_chance_temp = mtth:ai_chance_for_selecting_idea_group_[IDEA_GROUP] }
									}
									IDEA_GROUP = "[?v]"
								}
								add = ai_chance_temp
							}
						}
					}
				}
			}
			dip_idea_groups_gridbox = {
				array = global.dip_idea_groups
				entry_container = "[This.GetEu4StyleIdeasSelectableIdeaGroupEntryWindow]"

				ai_weights = {
					select_idea_group_button_click = {
						ai_will_do = {
							base = 0
							modifier = {
								set_temp_variable = { ai_chance_temp = 0 }
								meta_trigger = {
									text = {
										set_temp_variable = { ai_chance_temp = mtth:ai_chance_for_selecting_idea_group_[IDEA_GROUP] }
									}
									IDEA_GROUP = "[?v]"
								}
								add = ai_chance_temp
							}
						}
					}
				}
			}
			mil_idea_groups_gridbox = {
				array = global.mil_idea_groups
				entry_container = "[This.GetEu4StyleIdeasSelectableIdeaGroupEntryWindow]"

				ai_weights = {
					select_idea_group_button_click = {
						ai_will_do = {
							base = 0
							modifier = {
								set_temp_variable = { ai_chance_temp = 0 }
								meta_trigger = {
									text = {
										set_temp_variable = { ai_chance_temp = mtth:ai_chance_for_selecting_idea_group_[IDEA_GROUP] }
									}
									IDEA_GROUP = "[?v]"
								}
								add = ai_chance_temp
							}
						}
					}
				}
			}
		}

		properties = {
			icon = {
				image = "[This.GetIdeaGroupIcon]"
			}
			resource_icon = {
				image = "[This.GetIdeaGroupResourceIcon]"
			}
			idea_icon_1 = {
				image = "[This.GetIdeaPicture1]"
			}
			idea_icon_2 = {
				image = "[This.GetIdeaPicture2]"
			}
			idea_icon_3 = {
				image = "[This.GetIdeaPicture3]"
			}
			idea_icon_4 = {
				image = "[This.GetIdeaPicture4]"
			}
			idea_icon_5 = {
				image = "[This.GetIdeaPicture5]"
			}
			idea_icon_6 = {
				image = "[This.GetIdeaPicture6]"
			}
			idea_icon_7 = {
				image = "[This.GetIdeaPicture7]"
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 84
		ai_test_variance = 1

		ai_check = {
			has_variable = show_selectable_idea_groups_window
			NOT = { has_variable = show_ideas_window_confirm_alert }
		}

		ai_weights = {
			close_button_click = {
				ai_will_do = {
					factor = 0.01
				}
			}
		}
	}

	ideas_window_confirm_alert = {
		context_type = player_context

		window_name = "ideas_window_confirm_alert"

		visible = {
			is_ai = no
			has_variable = show_ideas_window_confirm_alert
		}

		effects = {
			cancel_button_click = {
				clear_variable = show_ideas_window_confirm_alert
				clear_variable = confirm_idea_group
				clear_variable = confirm_idea
				clear_variable = confirm_policy
				update_selectable_idea_groups_window = yes
				update_policy_window = yes
				update_main_ideas_window = yes
			}
			accept_button_click = {
				if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert < 4 }
					}
					set_temp_variable = { v = confirm_idea_group }
				}
				else = {
					set_temp_variable = { v = confirm_policy }
				}
				if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 1 }
					}
					select_idea_group_effect = yes
					scoped_sound_effect = "new_eu4_like_national_idea_unlocked"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 2 }
					}
					set_temp_variable = { pp_to_pay = idea_cost_var }
					multiply_temp_variable = { pp_to_pay = -1 }
					add_political_power = pp_to_pay
					meta_effect = {
						text = {
							complete_[IDEA]_idea_of_group = yes
						}
						IDEA = "[?confirm_idea]"
					}
					scoped_sound_effect = "click_accept_select_eu4_like_idea"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 3 }
					}
					remove_idea_group_effect = yes
					scoped_sound_effect = "disband"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 4 }
					}
					add_policy = yes
					set_variable = { show_ideas_window = 1 }
					clear_variable = show_policies_window
					clear_array = selectable_policies_array
					scoped_sound_effect = "click_select_eu4_like_idea"
				}
				else_if = {
					limit = {
						check_variable = { show_ideas_window_confirm_alert = 5 }
					}
					remove_policy = yes
					scoped_sound_effect = "disband"
				}
				clear_variable = show_ideas_window_confirm_alert
				clear_variable = confirm_idea_group
				clear_variable = confirm_idea
				clear_variable = confirm_policy
				update_selectable_idea_groups_window = yes
				update_policy_window = yes
				update_main_ideas_window = yes
			}
		}
	}

	ideas_window_national_idea_unlocked_alert = {
		context_type = player_context

		window_name = "ideas_window_national_idea_unlocked_alert"

		dirty = show_ideas_window_national_idea_unlocked_alert

		visible = {
			is_ai = no
			has_variable = show_ideas_window_national_idea_unlocked_alert
			NOT = { has_country_flag = disabled_ideas_window_national_idea_unlocked_alert }
		}

		effects = {
			ok_button_click = {
				clear_variable = show_ideas_window_national_idea_unlocked_alert
			}
			message_settings_button_click = {
				clear_variable = show_ideas_window_national_idea_unlocked_alert
				set_country_flag = disabled_ideas_window_national_idea_unlocked_alert
			}
			left_flag_click = {
				capital_scope = {
					ROOT = {
						goto_state = PREV
					}
				}
			}
			right_flag_click = {
				capital_scope = {
					ROOT = {
						goto_state = PREV
					}
				}
			}
		}

		properties = {
			left_flag = {
				image = "[This.GetFlag]"
			}
			right_flag = {
				image = "[This.GetFlag]"
			}
		}
	}

	# With La Resistance
	eu4_like_ideas_alerts_window_lar = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_window_lar"
		parent_window_token = top_bar

		visible = {
			is_ai = no
			has_dlc = "La Resistance"
			OR = {
				NOT = { check_variable = { eu4_like_ideas_alerts^0 = 0 } }
				can_remove_flags_for_available_dismissed_alerts = yes
			}
		}

		effects = {
			eu4_like_ideas_alerts_dismissed_alerts_button_click = {
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
			}

			alert_button_click = {
				clear_variable = show_ideas_window
				clear_variable = show_selectable_idea_groups_window
				clear_variable = show_policies_window
				clear_array = selectable_policies_array
				if = {
					limit = {
						OR = {
							check_variable = { v = 1 }
							check_variable = { v = 2 }
						}
					}
					set_variable = { show_ideas_window = 1 }
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					set_variable = { show_policies_window = 1 }
					update_policies_effect = yes
				}
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
				update_main_ideas_window = yes
			}
			alert_button_right_click = {
				meta_effect = {
					text = {
						if = {
							limit = {
								has_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
							}
							clr_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
						}
						set_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_right_click = {
				meta_effect = {
					text = {
						set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_shift_right_click = {
				if = {
					limit = {
						check_variable = { v = 3 }
					}
					set_variable = { show_eu4_like_ideas_alerts_policies_options_window = 1 }
				}
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			eu4_like_ideas_alerts_dismissed_alerts_button_visible = {
				can_remove_flags_for_available_dismissed_alerts = yes
			}

			alert_button_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			alert_icon_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			yellow_alert_glow_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_alerts_gridbox = {
				array = eu4_like_ideas_alerts
				entry_container = eu4_like_ideas_alerts_entry
			}
		}

		properties = {
			alert_icon = {
				frame = v
			}
		}
	}

	# Without La Resistance
	eu4_like_ideas_alerts_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_window"
		parent_window_token = top_bar

		visible = {
			is_ai = no
			NOT = { has_dlc = "La Resistance" }
			OR = {
				NOT = { check_variable = { eu4_like_ideas_alerts^0 = 0 } }
				can_remove_flags_for_available_dismissed_alerts = yes
			}
		}

		effects = {
			eu4_like_ideas_alerts_dismissed_alerts_button_click = {
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
			}

			alert_button_click = {
				clear_variable = show_ideas_window
				clear_variable = show_selectable_idea_groups_window
				clear_variable = show_policies_window
				clear_array = selectable_policies_array
				if = {
					limit = {
						OR = {
							check_variable = { v = 1 }
							check_variable = { v = 2 }
						}
					}
					set_variable = { show_ideas_window = 1 }
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					set_variable = { show_policies_window = 1 }
					update_policies_effect = yes
				}
				remove_flags_for_available_dismissed_alerts = yes
				refresh_eu4_like_alerts = yes
				update_main_ideas_window = yes
			}
			alert_button_right_click = {
				meta_effect = {
					text = {
						if = {
							limit = {
								has_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
							}
							clr_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
						}
						set_country_flag = temporarily_disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_right_click = {
				meta_effect = {
					text = {
						set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				remove_from_array = { eu4_like_ideas_alerts = v }
			}
			alert_button_control_shift_right_click = {
				if = {
					limit = {
						check_variable = { v = 3 }
					}
					set_variable = { show_eu4_like_ideas_alerts_policies_options_window = 1 }
				}
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			eu4_like_ideas_alerts_dismissed_alerts_button_visible = {
				can_remove_flags_for_available_dismissed_alerts = yes
			}

			alert_button_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			alert_icon_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
			yellow_alert_glow_visible = {
				if = {
					limit = {
						check_variable = { v = 1 }
					}
					can_select_any_idea = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 2 }
					}
					can_select_any_idea_group = yes
				}
				else_if = {
					limit = {
						check_variable = { v = 3 }
					}
					can_select_any_policy = yes
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_alerts_gridbox = {
				array = eu4_like_ideas_alerts
				entry_container = eu4_like_ideas_alerts_entry
			}
		}

		properties = {
			alert_icon = {
				frame = v
			}
		}
	}

	eu4_like_ideas_alerts_policies_options_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_policies_options_window"

		dirty = show_eu4_like_ideas_alerts_policies_options_window

		visible = {
			is_ai = no
			has_variable = show_eu4_like_ideas_alerts_policies_options_window
		}

		effects = {
			close_button_click = {
				clear_array = eu4_like_ideas_deactivated_alerts_options_array
				clear_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
				clear_variable = show_eu4_like_ideas_alerts_policies_options_window
			}
			open_side_menu_button_click = {
				clear_array = eu4_like_ideas_deactivated_alerts_options_array
				for_loop_effect = {
					start = 0
					end = 3
					value = j
					set_temp_variable = { j_temp = j }
					add_to_temp_variable = { j_temp = 1 }
					add_to_array = { eu4_like_ideas_deactivated_alerts_options_array = j_temp }
				}
				set_variable = { show_eu4_like_ideas_alerts_policies_options_side_menu_window = 1 }
				update_alerts_policies_options_window = yes
			}
			close_side_menu_button_click = {
				clear_array = eu4_like_ideas_deactivated_alerts_options_array
				clear_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
				update_alerts_policies_options_window = yes
			}

			select_button_click = {
				remove_from_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
			select_button_shift_click = {
				clear_array = deactivated_policies_for_alert
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
			deselect_button_click = {
				add_to_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
			deselect_button_shift_click = {
				clear_array = deactivated_policies_for_alert
				for_each_loop = {
					array = global.all_possible_policies
					value = j
					add_to_array = { deactivated_policies_for_alert = j }
				}
				refresh_eu4_like_alerts = yes
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			open_side_menu_button_visible = {
				NOT = { has_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window }
			}
			close_side_menu_button_visible = {
				has_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
			}

			select_button_visible = {
				is_in_array = { deactivated_policies_for_alert = v }
			}
			deselect_button_visible = {
				NOT = { is_in_array = { deactivated_policies_for_alert = v } }
			}
			icon_to_get_required_policies_tt_visible = {
				set_temp_variable = { policy_out_of_context = v }
				has_completed_required_idea_groups_for_policy = yes
				hidden_trigger = {
					always = no
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_alerts_policies_options_gridbox = {
				array = global.all_possible_policies
				entry_container = eu4_like_ideas_alerts_policies_options_entry
			}
		}
	}

	eu4_like_ideas_alerts_policies_options_side_menu_panel = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_policies_options_side_menu_panel"
		parent_window_name = "eu4_like_ideas_alerts_policies_options_window"

		visible = {
			always = yes
		}
	}

	eu4_like_ideas_alerts_policies_options_side_menu_window = {
		context_type = player_context

		window_name = "eu4_like_ideas_alerts_policies_options_side_menu_window"
		parent_window_name = "eu4_like_ideas_alerts_policies_options_side_menu_panel_instance"

		visible = {
			is_ai = no
			has_variable = show_eu4_like_ideas_alerts_policies_options_side_menu_window
		}

		effects = {
			select_button_click = {
				meta_effect = {
					text = {
						set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
			select_button_shift_click = {
				for_each_loop = {
					array = eu4_like_ideas_deactivated_alerts_options_array
					value = j
					meta_effect = {
						text = {
							set_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
						}
						ALERT = "[?j]"
					}
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
			deselect_button_click = {
				meta_effect = {
					text = {
						clr_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
			deselect_button_shift_click = {
				for_each_loop = {
					array = eu4_like_ideas_deactivated_alerts_options_array
					value = j
					meta_effect = {
						text = {
							clr_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
						}
						ALERT = "[?j]"
					}
				}
				clear_array = eu4_like_ideas_alerts
				refresh_eu4_like_alerts = yes
			}
		}

		triggers = {
			select_button_visible = {
				meta_trigger = {
					text = {
						NOT = { has_country_flag = disabled_eu4_like_ideas_alerts_[ALERT] }
					}
					ALERT = "[?v]"
				}
			}
			deselect_button_visible = {
				meta_trigger = {
					text = {
						has_country_flag = disabled_eu4_like_ideas_alerts_[ALERT]
					}
					ALERT = "[?v]"
				}
			}
		}

		dynamic_lists = {
			eu4_like_ideas_deactivated_alerts_options_gridbox = {
				array = eu4_like_ideas_deactivated_alerts_options_array
				entry_container = eu4_like_ideas_deactivated_alerts_options_entry
			}
		}
	}

	policies_window = {
		context_type = player_context

		window_name = "policies_window"

		dirty = show_policies_window

		visible = {
			has_variable = show_policies_window
		}

		effects = {
			close_button_click = {
				set_variable = { show_ideas_window = 1 }
				clear_variable = show_policies_window
				clear_array = selectable_policies_array
			}
			alert_settings_button_click = {
				if = {
					limit = {
						NOT = { has_variable = show_eu4_like_ideas_alerts_policies_options_window }
					}
					set_variable = { show_eu4_like_ideas_alerts_policies_options_window = 1 }
				}
				else = {
					clear_variable = show_eu4_like_ideas_alerts_policies_options_window
				}
			}

			select_policy_button_click = {
				if = {
					limit = {
						is_ai = no
					}
					set_variable = { show_ideas_window_confirm_alert = 4 }
					set_variable = { confirm_policy = v }
				}
				else = {
					add_policy = yes
					set_variable = { show_ideas_window = 1 }
					clear_variable = show_policies_window
					clear_array = selectable_policies_array
				}
			}
			activate_policy_for_alert_button_click = {
				remove_from_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_policy_window = yes
				update_alerts_policies_options_window = yes
			}
			deactivate_policy_for_alert_button_click = {
				add_to_array = { deactivated_policies_for_alert = v }
				refresh_eu4_like_alerts = yes
				update_policy_window = yes
				update_alerts_policies_options_window = yes
			}
		}

		triggers = {
			close_button_click_enabled = {
				NOT = { has_variable = show_ideas_window_confirm_alert }
			}
			no_policies_available_info_visible = {
				check_variable = { selectable_policies_array^num < 1 }
			}
			alert_settings_button_visible = {
				is_ai = no
			}

			select_policy_button_click_enabled = {
				has_not_selected_max_amount_of_policies = yes
				set_temp_variable = { policy_out_of_context = v }
				has_completed_required_idea_groups_for_policy = yes
			}
			activate_policy_for_alert_button_visible = {
				is_in_array = { deactivated_policies_for_alert = v }
			}
			deactivate_policy_for_alert_button_visible = {
				NOT = { is_in_array = { deactivated_policies_for_alert = v } }
			}
		}

		dynamic_lists = {
			selectable_policies_gridbox = {
				array = selectable_policies_array
				entry_container = selectable_policies_entry

				ai_weights = {
					select_policy_button_click = {
						ai_will_do = {
							factor = 2
						}
					}
				}
			}
		}

		properties = {
			policy_icon = {
				image = "[This.GetPolicyPicture]"
			}
		}

		ai_enabled = {
			always = yes
		}

		ai_test_interval = 48
		ai_test_variance = 1

		ai_check = {
			has_variable = show_policies_window
			NOT = { has_variable = show_ideas_window_confirm_alert }
		}

		ai_weights = {
			close_button_click = {
				ai_will_do = {
					factor = 1
				}
			}
		}
	}
}