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;
};

/**
 * Available environments for the Connect Onboarding service.
 *
 * - `"local"` - Local development environment (http://localhost:4204)
 * - `"dev"` - Development environment for early-stage testing
 * - `"cert"` - Certificate/staging environment for integration testing
 * - `"prod"` - Live production environment for real applications
 *
 * Exported so integrators can type the `env` prop (ID-4534).
 */
export 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;
};

/**
 * A React wrapper component for the Connect Onboarding product.
 *
 * @param props - Component properties
 * @param jwt - JWT token for authentication (required)
 * @param env - Target environment ("local" | "dev" | "cert" | "prod"). Omit for prod; init-only
 * @param theme - Theme mode ("auto" | "light" | "dark", defaults to "auto")
 * @param onboardingFlow - Onboarding experience ("full_with_tax" | "full_without_tax" | "tax_only"); init-only
 * @param onCompleted - Callback invoked when the sell flow is successfully completed
 * @param onError - Callback invoked when an error occurs
 * @param onClose - Callback invoked when the user closes the widget
 * @param onLoaded - Callback invoked when the widget has finished loading
 * @param onEvent - Callback invoked for general application events
 *
 * @example
 * ```tsx
 * // Basic usage with production environment (default)
 * <Onboarding jwt="your-jwt-token" />
 *
 * // Using cert environment for testing
 * <Onboarding jwt="your-jwt-token" env="cert" />
 *
 * // Force dark theme
 * <Onboarding jwt="your-jwt-token" theme="dark" />
 *
 * // With callback functions
 * <Onboarding
 *   jwt="your-jwt-token"
 *   theme="light"
 *   onLoaded={() => console.log('Crypto sell loaded and ready')}
 *   onCompleted={({ amountSold, assetSymbol }) => console.log('Sold', amountSold, assetSymbol)}
 *   onClose={() => console.log('Crypto sell closed')}
 *   onError={({ errorCode, reason }) => console.error('Error:', errorCode, reason)}
 *   onEvent={(event) => console.log('Event:', event)}
 * />
 * ```
 *
 * @returns React component that renders the Connect Onboarding interface
 */
export declare const Onboarding: default_2.FC<OnboardingProps>;

declare type OnboardingCompletedData = {
    participantCode: string;
    kycStatus: string;
};

declare type OnboardingEvent = AppEvent<OnboardingEventType>;

declare type OnboardingEventType = string;

/**
 * Onboarding experience to render.
 *
 * - `"full_with_tax"` - Full onboarding plus brokerage tax certification
 * - `"full_without_tax"` - Full onboarding, no tax certification
 * - `"tax_only"` - Tax certification only, for existing participants
 */
export declare type OnboardingFlow = 'full_with_tax' | 'full_without_tax' | 'tax_only';

declare interface OnboardingProps {
    /**
     * JWT token used for authentication with the Connect Onboarding service.
     * This token should be obtained from your backend and contain the necessary
     * claims for user identification and authorization.
     *
     * The SDK does not support refresh tokens and does not renew tokens on its
     * own. To handle renewal, fetch a new JWT from your backend and pass it as
     * this prop.
     *
     * @example "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
     */
    jwt: string;
    /**
     * Target environment for the Connect Onboarding service.
     *
     * @default "prod"
     *
     * Omit for production. `env` is init-only: it's read once when the widget
     * mounts and locks the iframe URL — changing it afterward has no effect.
     * Region (EU) routing is derived from the JWT, not from `env`.
     *
     * Available environments:
     * - `"local"` - Local development environment
     * - `"dev"` - Development environment
     * - `"cert"` - Certificate/staging environment for integration testing
     * - `"prod"` - Live production environment for real applications
     *
     * @example
     * ```tsx
     * // Use production (default)
     * <Onboarding jwt={token} />
     *
     * // Use cert for testing
     * <Onboarding jwt={token} env="cert" />
     * ```
     */
    env?: Environment;
    /**
     * Theme mode for the Connect Onboarding interface.
     *
     * @default "auto"
     *
     * Available themes:
     * - `"auto"` - Automatically detect system preference (light/dark mode)
     * - `"light"` - Force light theme
     * - `"dark"` - Force dark theme
     *
     * @example
     * ```tsx
     * // Auto-detect system preference (default)
     * <Onboarding jwt={token} />
     *
     * // Force dark theme
     * <Onboarding jwt={token} theme="dark" />
     * ```
     */
    theme?: Theme;
    /**
     * Onboarding experience to render. Optional; when omitted the default
     * experience is used. Init-only: post-mount changes are ignored.
     *
     * @example
     * ```tsx
     * <Onboarding jwt={token} onboardingFlow="full_without_tax" />
     * ```
     */
    onboardingFlow?: OnboardingFlow;
    /**
     * Callback invoked when the crypto sell flow is successfully completed.
     *
     * @param data - Details about the completed sell, including amount sold and asset symbol
     *
     * @example
     * ```tsx
     * <Onboarding
     *   jwt={token}
     *   onCompleted={({ amountSold, assetSymbol }) =>
     *     console.log(`Sold ${amountSold} ${assetSymbol}`)
     *   }
     * />
     * ```
     */
    onCompleted?: (data: OnboardingCompletedData) => void;
    /**
     * Callback invoked when an error occurs during the crypto sell flow.
     *
     * @param error - Error details including error code and reason
     *
     * @example
     * ```tsx
     * <Onboarding
     *   jwt={token}
     *   onError={({ errorCode, reason }) =>
     *     console.error('Crypto sell error:', errorCode, reason)
     *   }
     * />
     * ```
     */
    onError?: (error: ErrorPayload) => void;
    /**
     * Callback invoked when the user closes the crypto sell widget.
     *
     * @example
     * ```tsx
     * <Onboarding
     *   jwt={token}
     *   onClose={() => setShowOnboarding(false)}
     * />
     * ```
     */
    onClose?: () => void;
    /**
     * Callback invoked when the crypto sell widget has finished loading and is ready.
     *
     * @example
     * ```tsx
     * <Onboarding
     *   jwt={token}
     *   onLoaded={() => setIsLoading(false)}
     * />
     * ```
     */
    onLoaded?: () => void;
    /**
     * Callback invoked for general application events during the crypto sell flow.
     *
     * @param event - Event object containing the event type and associated data
     *
     * @example
     * ```tsx
     * <Onboarding
     *   jwt={token}
     *   onEvent={(event) => console.log('Crypto sell event:', event)}
     * />
     * ```
     */
    onEvent?: (event: OnboardingEvent) => void;
}

/**
 * Theme mode for the Connect Onboarding 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 {
            /**
             * Connect Onboarding web component element
             */
            [WEB_COMPONENT_TAG]: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
                /**
                 * JWT token for authentication
                 */
                jwt: string;
                /**
                 * Target environment ("local" | "dev" | "cert" | "prod").
                 * Omit for prod; init-only.
                 */
                env?: Environment;
                /**
                 * Theme mode ("auto" | "light" | "dark")
                 */
                theme?: Theme;
                /**
                 * Onboarding experience to render. camelCase so React 19 sets it as a
                 * property before `connectedCallback` runs.
                 */
                onboardingFlow?: OnboardingFlow;
            };
        }
    }
}
