import type { TurboModule } from 'react-native';
import { TurboModuleRegistry } from 'react-native';
import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';

export interface Spec extends TurboModule {
  finish(): void;
  isFlowOpen(): Promise<boolean>;

  registerStepHandoff(): void;
  unregisterStepHandoff(): void;
  // Reports a typed handoff outcome for a specific delivered handoff and resumes
  // the flow. `handoffId` correlates the call back to the native pending handoff
  // (TurboModule callbacks can't hold per-call closures). `outcome` is always
  // required on the wire — the bare `complete()` case is normalized to
  // `{ kind: 'done' }` in the JS wrapper before crossing the bridge (NAM-1560 §2.8).
  completeHandoff(handoffId: string, outcome: UnsafeObject): void;
  resume(): void;
  pause(): void;
  registerEventHandler(): void;
  unregisterEventHandler(): void;
  purchaseSuccess(): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('RNNamiFlowManager');
