@cooldown = 3600

commercial_pact_no = {
	potential = { always = yes }
	allow = {
		custom_tooltip = {
			NOT = {
				AND = {
					NOT = { has_federation_law = commercial_pact_no }
					has_modifier = federation_law_category_commercial_pact_cooldown
					has_any_federation_law_in_category = law_category_commercial_pact
				}
			}
		}
	}
	# Baseline option, also the auto-assigned default. Kept benign (no cohesion cost, no cooldown) so the
	# default assignment at federation creation is harmless.
	on_enact = {
		set_federation_settings = {
			commercial_pact = no
		}
		if = {
			limit = { has_nomads_dlc = yes }
			set_federation_settings = {
				waystation_pact = no
			}
		}
	}

	ai_weight = {
		base = 10
	}
}

commercial_pact_yes = {
	potential = {
		NOT = { has_federation_flag = special_federation }
	}
	allow = {
		custom_tooltip = {
			NOT = {
				AND = {
					NOT = { has_federation_law = commercial_pact_yes }
					has_modifier = federation_law_category_commercial_pact_cooldown
					has_any_federation_law_in_category = law_category_commercial_pact
				}
			}
		}
	}
	required_centralization = {
		base = 5
		# The Galactic Union (default) unlocks the law one centralization tier earlier than other federation types.
		modifier = {
			add = -1
			has_federation_type = default_federation
		}
	}
	on_enact = {
		set_federation_settings = {
			commercial_pact = yes
		}
		if = {
			limit = { has_nomads_dlc = yes }
			set_federation_settings = {
				waystation_pact = yes
			}
		}
		if = {
			limit = { has_federation_flag = enable_federation_cooldowns }
			add_modifier = {
				modifier = federation_law_category_commercial_pact_cooldown
				days = @cooldown
			}
		}
		add_cohesion = -5
	}

	ai_weight = {
		base = 0

		#Personalities
		modifier = {
			desc = federation_acceptance_ruthless_capitalists
			add = 25
			has_ai_personality = ruthless_capitalists
		}
		modifier = {
			desc = federation_acceptance_peaceful_traders
			add = 25
			has_ai_personality = peaceful_traders
		}
		modifier = {
			desc = federation_acceptance_migrating_flock
			add = 50
			has_ai_personality = migrating_flock
		}

		#Government
		modifier = {
			desc = federation_acceptance_corporate
			add = 15
			is_megacorp = yes
		}

		#Civics
		modifier = {
			desc = gal_com_supporting_civics
			add = 15
			OR = {
				has_civic = civic_merchant_guilds
				has_civic = civic_corporate_dominion
				has_civic = civic_free_traders
				has_civic = civic_trading_posts
				is_caravan_masters_empire = yes
			}
		}

		#Nomadic empires
		modifier = {
			desc = federation_acceptance_nomadic
			add = 25
			is_nomadic = yes
		}

		#Ethics
		modifier = {
			desc = federation_acceptance_xenophobe
			add = -15
			is_xenophobe = yes
		}
	}
}
