AIGameSettingControls.Support = class extends AIGameSettingControlInt
{
	constructor(...args)
	{
		super(...args);
		this.defaultValue = 1500;
		g_GameSettings.playerAI.watch(() => this.render(), ["values"]);
	}

	onOpenPage(playerIndex, enabled)
	{
		super.onOpenPage(playerIndex, enabled);
		this.render();
	}

	render()
	{
		const ai = g_GameSettings.playerAI.get(this.playerIndex);
		this.setHidden(!ai);
		if (ai)
		{
			const value = ai.priorities?.support ?? this.defaultValue;
			this.setIntValue(value);
		}
	}

	onValueChange(value)
	{
		const ai = g_GameSettings.playerAI.get(this.playerIndex);
		const priorities = ai && ai.priorities ? { ...ai.priorities, "support": value } : { "support": value };
		g_GameSettings.playerAI.setPriorities(this.playerIndex, priorities);
		this.gameSettingsController.setNetworkInitAttributes();
	}
};

AIGameSettingControls.Support.prototype.TitleCaption =
	translate("Support");
