import { default as default_2 } from 'react';

/**
 * Generic app event structure
 * @template TType - Event type string
 * @template TData - Event data payload
 */
declare type AppEvent<TType extends string = string, TData = Record<string, unknown>> = {
    /** The type of event that occurred */
    type: TType;
    /** Data associated with the event */
    data: TData;
};

/**
 * A React wrapper component for the Connect Crypto Deposits product.
 */
export declare const CryptoDeposits: default_2.FC<CryptoDepositsProps>;

declare type CryptoDepositsCompletedData = {
    depositId: string;
    assetSymbol: string;
    network: string;
    amount: string;
};

declare type CryptoDepositsEvent = AppEvent<CryptoDepositsEventType>;

declare type CryptoDepositsEventType = string;

declare interface CryptoDepositsProps {
    /** JWT token used for authentication with the Connect Crypto Deposits service. */
    jwt: string;
    /** Target environment for the Connect Crypto Deposits service. @default "prod" */
    env?: Environment;
    /** Theme mode for the Connect Crypto Deposits interface. @default "auto" */
    theme?: Theme;
    /**
     * App link that brings the user back to the host app from another app, such
     * as a wallet after a WalletConnect approval: an https universal/app link or a
     * custom-scheme deep link. Set by the native SDK shells only. Browser
     * embeddings ignore it.
     */
    appRedirectUrl?: string;
    /** Callback invoked when the crypto deposit flow is successfully completed. */
    onCompleted?: (data: CryptoDepositsCompletedData) => void;
    /**
     * Callback invoked when a deposit transaction reaches a terminal **failed**
     * state (the "Transaction failed" page). Distinct from `onError` — this
     * carries the failed transaction's details, not an SDK/request error.
     *
     * @param data - Details about the failed transaction (depositId, assetSymbol, network, amount)
     */
    onFailed?: (data: CryptoDepositsCompletedData) => void;
    /**
     * Callback invoked when a deposit made from an external funding source
     * changes status. This is the "auth as a feature" path; the manual-deposit
     * path reports through `onCompleted`/`onFailed` instead.
     *
     * A status notification, not a single terminal event: it can fire more than
     * once for one deposit, including while account matching is still verifying.
     * Read `deposit.data.status.value` (`CONFIRMED` = funded, `FAILED` = not) and
     * `deposit.data.accountMatchingValidation?.status` (`PENDING` = not finished
     * yet) rather than assuming any call is the last one.
     *
     * @param deposit - The deposit and its current status
     */
    onDeposit?: (deposit: DepositCompletedPayload) => void;
    /** Callback invoked when an error occurs during the crypto deposit flow. */
    onError?: (error: ErrorPayload) => void;
    /** Callback invoked when the user closes the crypto deposits widget. */
    onClose?: () => void;
    /** Callback invoked when the crypto deposits widget has finished loading and is ready. */
    onLoaded?: () => void;
    /** Callback invoked for general application events during the crypto deposit flow. */
    onEvent?: (event: CryptoDepositsEvent) => void;
}

/**
 * Deposit completed payload — emitted by SDKs that drive a deposit through
 * the integrations flow. Lives on `CommonCallbacks` because both Auth and
 * any SDK embedding `@zerohash/integrations-flow` (e.g. fund with `useAuth`)
 * resolve through the same deposit-status hook.
 */
declare type DepositCompletedPayload = {
    data: {
        depositId: string;
        status: DepositStatus;
        assetId: string;
        networkId: string;
        amount?: string;
        accountMatchingValidation?: {
            status: 'PENDING' | 'VALID' | 'INVALID' | 'ERROR';
            reason?: string;
        };
    };
};

/**
 * Deposit status object — shared across SDKs that surface deposit completion.
 */
declare type DepositStatus = {
    value: string;
    details: string;
    occurredAt: string;
};

/**
 * Available environments for the Connect Crypto Deposits service.
 *
 * - `"local"` - Local development environment
 * - `"dev"` - Development environment for early-stage testing
 * - `"cert"` - Certificate/staging environment for integration testing
 * - `"prod"` - Live production environment for real applications
 */
declare type Environment = 'local' | 'dev' | 'cert' | 'prod';

/**
 * Generic error codes for all Connect applications
 */
declare enum ErrorCode {
    /** Network connectivity error */
    NETWORK_ERROR = 'network_error',
    /** Authentication or session expired error */
    AUTH_ERROR = 'auth_error',
    /** Resource not found error */
    NOT_FOUND_ERROR = 'not_found_error',
    /** Validation error from user input */
    VALIDATION_ERROR = 'validation_error',
    /** Server error (5xx) */
    SERVER_ERROR = 'server_error',
    /** Client error (4xx) */
    CLIENT_ERROR = 'client_error',
    /** Unknown or unexpected error */
    UNKNOWN_ERROR = 'unknown_error',
}

/**
 * Generic error payload structure for error callbacks
 */
declare type ErrorPayload = {
    /** Error code indicating the type of error */
    errorCode: ErrorCode;
    /** Human-readable reason for the error */
    reason: string;
};

/**
 * Theme mode for the Connect Crypto Deposits interface.
 *
 * - `"auto"` - Automatically detect system preference (light/dark mode)
 * - `"light"` - Force light theme
 * - `"dark"` - Force dark theme
 */
declare type Theme = 'auto' | 'light' | 'dark';

export { }


declare global {
    namespace JSX {
        interface IntrinsicElements {
            [WEB_COMPONENT_TAG]: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
                jwt: string;
                env?: Environment;
                theme?: Theme;
            };
        }
    }
}
