is_merc_enclave_founding_allowed = {
	owner = {
		NOR = {
			AND = {
				has_ethic = ethic_gestalt_consciousness
				NOR = {
					has_valid_civic = civic_machine_tactical_algorithms
					# Libra: Gestalt Age
					inline_script = {
						script = merger_of_rules/toggled_code
						code = "
							has_ascension_perk = ap_libra_gestalt_release_vassals
						"
						toggle = @libra_mod
					}
				}
			}
			has_civic = civic_fanatic_purifiers
		}
	}
	custom_tooltip = {
		fail_text = enclave.2.tooltip.a
		success_text = enclave.2.tooltip.aa
		exists = owner
		exists = leader
		is_ship_class = shipclass_military
	}
	fleet_size >= 50
	custom_tooltip = {
		fail_text = enclave.2.tooltip.cloak
		count_owned_ship = {
			limit = { has_cloaking_strength > 0 }
			count = 0
		}
	}
	custom_tooltip = {
		fail_text = enclave.2.tooltip.c
		success_text = enclave.2.tooltip.cc
		exists = solar_system
		solar_system = {
			exists = owner
			owner = {
				is_same_value = prevprev.owner
				is_same_value = prevprev.controller
			}
			NOT = {
				any_fleet_in_system = {
					owner = {
						is_hostile = prevprev.owner
					}
				}
			}
		}
	}
	custom_tooltip = {
		fail_text = enclave.2.tooltip.b
		success_text = enclave.2.tooltip.bb
		exists = solar_system # vfix
		solar_system = {
			NOR = {
				any_fleet_in_system = {
					is_ship_size = enclave_mercenary_station
				}
				has_star_flag = enclave
			}
		}
	}
	custom_tooltip = {
		fail_text = enclave.2.tooltip.e
		success_text = enclave.2.tooltip.ee
		exists = solar_system # vfix
		solar_system = {
			OR = {
				any_system_planet = {
					is_moon = yes
				}
				any_system_planet = {
					is_asteroid = yes
				}
			}
		}
	}
	custom_tooltip = {
		fail_text = enclave.2.tooltip.d
		success_text = enclave.2.tooltip.dd
		controller = {
			enclave_capacity_left >= 1
		}
	}
	custom_tooltip = {
		fail_text = enclave.2.tooltip.f
		NOR = {
			has_ship_owner_type = federation
			has_ship_owner_type = galactic_community
		}
	}
	custom_tooltip = {
		fail_text = enclave.2.tooltip.g
		NOT = {
			any_owned_ship = {
				is_space_fauna = yes
			}
		}
	}
	# Warship Girls R And MIST Species
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = cannot_sold_wg_fleet
				NOT = {
					any_controlled_ship = {
						is_wg_event_limit_ships = yes
					}
				}
			}
		"
		toggle = @wsg_mod
	}
	# Star Wars: Kuat Ancient Empire
	inline_script = {
		script = merger_of_rules/toggled_code
		code = "
			custom_tooltip = {
				fail_text = cannot_sold_kuat_fleet
				NOT = {
					any_owned_ship = {
						kuat_is_flagship_system_protection = yes
					}
				}
			}
		"
		toggle = @sw_kuat_mod
	}
}
