/**
 * Client LMB default against world entities (snapshot fields only).
 * Aggressive hostiles prefer Attack even when they are also talkable.
 */

/**
 * @param {{
 *   untargetable?: boolean,
 *   characterId?: string|number|null,
 *   canFight?: boolean,
 *   mobTypeId?: string|number|null,
 *   talkable?: boolean,
 *   hasDialogue?: boolean,
 *   hasShop?: boolean,
 *   aggressive?: boolean,
 *   hostile?: boolean
 * }} entity
 * @returns {"inspect"|"attack"|"talk"|null}
 */
export function defaultLeftClickEntityAction (entity)
{
	if (!entity || entity.untargetable)
	{ return null; }
	if (entity.characterId)
	{ return "inspect"; }
	const attackable = !!entity.canFight
		|| (!!entity.mobTypeId && !entity.talkable);
	const aggressive = !!(entity.aggressive || entity.hostile);
	if (attackable && aggressive)
	{ return "attack"; }
	if (entity.hasDialogue || entity.talkable || entity.hasShop)
	{ return "talk"; }
	if (attackable)
	{ return "attack"; }
	return null;
}
