Hey MustAskQuestions, and welcome to the forum.
A word problem huh?
I definitely could give an exact answer to this, but I confess the only way I can do that to both ask you for a ton of other information and then basically step through my code figuring it out. This would be pretty time consuming.
I can give you some basic facts though:
1) The 50/50 HP guy with Infection isn't going to be a high priority. Infection isn't considered serious in most cases if the target has nothing they need to recover anyway.
2) Summoners are considered more important for healing than other allies. (Note: The player is not signaled out here: all AIs treat all summoners the same in this regard. That said, the player here is not considered to be in grave danger yet, the 20/50 demon is, so the 20/50 would get the first Mending, followed by the player. The 40/50 demon itself would likely not be Mended yet: the AI knows Mending is a one shot deal until the Mended status drops, and won't be willing to "waste" it on a target who won't receive the full effect.
3) Generally speaking, the AI *hates* moving, and views it as a last resort. If the AI has a valid target for Mending and/or Flame Dart, it will generally want to use that, HOWEVER...
4) ...there is a fuzzy element that kicks in as a demon's SP gets low that causes it to begin to become more open to passing/moving in order to keep its options open/conserve SP.
What I would expect here, assuming the situation somehow doesn't change in any other way during these turns*, would be:
1) Turn 1: Mend 20 HP demon
2) Turn 2: Mend 30 HP summoner
3) Turn 3: Flame Dart the enemy demon
4) Turn 4: SP is getting low... might Flame Dart, might move up
5) Turn 5: Depending on distance and SP, Flame Dart, move closer/Bask
6) Too hard to predict this far out
I don't know how helpful this answer is for what you want, but this is probably the most in depth I can spend time on before the build is done.
If there are specific points you'd like more info on, feel free to ask.
* - Probably worth adding the AI virtually never tries to "look ahead" in its considerations. Since many other characters act each turn and have a wide, wide variety of possible actions, it's not very effective to try to make multi-turn plans anyway: it's far too likely something will change and ruin whatever you were trying to set up. The major exceptions here are the movement AI and area-effect AI: movement AI code tries to keep allies clear of each others' lines of fire when needed, and area-effect AI will at least consider "waiting" a turn to fire an AE nuke if it thinks it can get more targets and doesn't feel it will likely lose any... but this is a VERY loose calculation and certainly not an exact science.