import { atom } from 'jotai';

// Bridge between the native Capacitor push-action listener (which fires outside
// any React render context) and the in-app call flow. The listener sets the
// atom; usePendingCallActionConsumer — mounted inside CallEmbedProvider — reads
// it and triggers switch-or-start / mx.sendRtcDecline.
export type PendingCallAction =
  | { kind: 'answer'; roomId: string; notifEventId?: string }
  | { kind: 'decline'; roomId: string; notifEventId: string };

export const pendingCallActionAtom = atom<PendingCallAction | undefined>(undefined);
