import type { PaymentGroupType } from '@funkit/api-base';
import type { SwappedTheme } from '../utils/swapped';
/**
 * Typed contract for the message bridge between the SDK and the embedded
 * Swapped flow. On web this is bridged over an `<iframe>` + `window.postMessage`
 * (see {@link createIframeSwappedTransport}); React Native will bridge the same
 * messages over a `WebView`. Freezing the event catalog here lets both
 * platforms share the `SwappedProvider` state machine and turns any drift in
 * the message shapes into a compile-time error.
 *
 * Reference: the inbound switch in `SwappedIframeController` and the sends in
 * `SwappedProvider`.
 *
 * This module is platform-agnostic and is slated to move to
 * `@funkit/connect-core/interfaces/` during the RN extraction.
 */
/**
 * Navigation steps reported by the Swapped embed. Open-ended — the embed may
 * emit steps we don't enumerate, which fall through to the default handler.
 */
export type SwappedStep = 'EMPTY' | 'KYC_ADDRESS' | 'KYC_AWAITING_IDENTITY' | 'KYC_IDENTITY' | 'KYC_PERSONAL' | 'KYC_SUMSUB' | 'LOGIN_EMAIL' | 'LOGIN_EMAIL_VERIFICATION' | 'PAYMENT' | 'ORDER_CONFIRMATION' | (string & {});
/**
 * Opaque payloads — the SDK never introspects these, it only forwards them to
 * analytics via `JSON.stringify`. Typed as `unknown` so callers must stringify
 * rather than read fields.
 */
export type SwappedErrorPayload = unknown;
export type SwappedTxPayload = unknown;
/** embed → parent */
export type SwappedInboundMessage = {
    type: 'SWAPPED_READY';
} | {
    type: 'SWAPPED_GO_BACK';
} | {
    type: 'SWAPPED_CLOSE';
} | {
    type: 'SWAPPED_NEW_DEPOSIT';
} | {
    type: 'SWAPPED_ERROR';
    data?: SwappedErrorPayload;
} | {
    type: 'SWAPPED_NAVIGATION';
    data?: {
        step?: SwappedStep;
    };
} | {
    type: 'SWAPPED_ORDER_DATA';
    data?: unknown;
} | {
    type: 'SWAPPED_TRANSACTION_SUCCESSFUL';
    data?: SwappedTxPayload;
} | {
    type: 'SWAPPED_LOGOUT';
};
/** parent → embed */
export type SwappedOutboundMessage = {
    type: 'SWAPPED_METHOD';
    method: PaymentGroupType;
} | {
    type: 'SWAPPED_THEME';
    data: SwappedTheme;
} | {
    type: 'SWAPPED_FOCUS';
};
export interface SwappedTransport {
    /**
     * Send a message to the embed. Returns `true` if the message was dispatched,
     * `false` if the embed isn't reachable yet (so callers can mirror today's
     * behavior of logging only on a successful send).
     */
    send(msg: SwappedOutboundMessage): boolean;
    /**
     * Subscribe to messages from the embed. The handler is only invoked for
     * messages whose origin has already been validated by the transport. Returns
     * an unsubscribe function.
     */
    onMessage(handler: (msg: SwappedInboundMessage) => void): () => void;
}
