[FE8] How does the game determine the pairing endings?

Does it search through all the support combination slots
checks which ones have A rating
and then which one of these have a paired set up ending?

If I replace the Eirika-Ephraim pair dual ending slot
with a new pair (and of course new ending text)
then in the support C/B/A conversation slot 1, change eirika-ephraim with the 2 new characters (of course also changing the support relations, growths and texts)
will it show the new pair in the ending?

Or is it more hardcoded separately, searching specific character IDs for a specific ending pair event?

How the whole ending-support availability works?