{expanded || preview === undefined ? text : preview}
+ {preview !== undefined && } + > +} + +/** The projection admits at most one card per turn; should several exist, the lowest call id is shown. */ +function proposalOf(view: ActionCardView | undefined, turn: number): ActionCardProposal | undefined { + let found: ActionCardProposal | undefined + for (const proposal of Object.values(view?.proposals ?? {})) { + if (proposal.turn === turn && (found === undefined || proposal.callId < found.callId)) found = proposal + } + return found +} + +function decisionOf(view: ActionCardView | undefined, callId: string): ActionCardDecision | undefined { + return view !== undefined && Object.hasOwn(view.decisions, callId) ? view.decisions[callId] : undefined +} + +/** + * Place the card admitted in a turn after that turn's final answer, once the turn has ended for any reason. + * @param props - Turn location, projection reader, registered bodies and Session-bound actions. + * @returns the card, or null. + */ +export function ActionCardTail({ turn, useProjection, ...props }: TailProps) { + const view = useProjection('actionCards') + const proposal = proposalOf(view, turn.turn) + const decision = proposal === undefined ? undefined : decisionOf(view, proposal.callId) + return proposal === undefined || decision?.phase === 'suppressed' || turn.end === undefined || turn.data.get('turn-tail')?.closing == null + ? null :{t(phase)}
} + {error !== undefined &&{t(error)}
} + {decision === undefined && } +{reason}
+ {inspect && }
+
+