import { ActionForm, ConnectErrorCode, IAmount, IAmountView, IMerchantAppointParam, IPaymentMethod } from '../../../types';
import AddressProcessor from './elementProcessor/addressProcessor';
import AuthProcessor from './elementProcessor/authProcessor';
import PaymentProcessor from './elementProcessor/paymentProcessor';
/**
 * element 消息事件名
 */
export declare enum ElementPaymentEvent {
    RENDER_COMPONENT = "renderComponent",
    CAPTURE_ASSET = "onCaptureAsset",
    SIGN_OUT = "onSignout",
    BLUR = "onBlur",
    SUBMIT_PAY = "submitPay",
    VALIDATE = "onValidate",
    SUBMIT_RISK = "onSubmitRisk",
    AFTER_SUBMIT = "onAfterSubmit",
    SIZE_CHANGE = "onSizeChange",
    LAUNCH = "onLaunch",
    CALLBACK = "callback",
    /**
     * @deprecated 已废弃 请使用eventCallback
     */
    SEND_MUITI_APP_EVENT_TO_SDK = "sendMuitiAppEventToSdk",
    LOG = "log",
    HANDLE_PAYMENT = "handlePayment",
    ON_EVENT_CALLBACK = "onEventCallback"
}
export declare enum ElementPaymentMethod {
    CONTAINER_ELEMENT = "CONTAINER_ELEMENT",
    AUTH_ELEMENT = "AUTH_ELEMENT",
    ADDRESS_ELEMENT = "ADDRESS_ELEMENT",
    PAYMENT_ELEMENT = "PAYMENT_ELEMENT"
}
export declare enum ElementType {
    auth = "auth",
    address = "address",
    payment = "payment"
}
/**
 * TODO 替换外外网链接
 * 支付状态参考: https://yuque.antfin.com/antom_ka_team/yg9y7x/fe8xxqgbivnx5fd2#rGgE
 */
export declare enum PaymentStatus {
    SUCCESS = "SUCCESS",
    PROCESSING = "PROCESSING",
    CANCELLED = "CANCELLED",
    PENDING = "PENDING",
    S = "SUCCESS",
    F = "FAIL",
    U = "PROCESSING",
    FAIL = "FAIL"
}
export declare const MountElementType: {
    auth: ElementPaymentMethod;
    address: ElementPaymentMethod;
    payment: ElementPaymentMethod;
    AUTH_ELEMENT: ElementType;
    ADDRESS_ELEMENT: ElementType;
    PAYMENT_ELEMENT: ElementType;
};
export declare enum ThemeType {
    NostalgicGray = "nostalgicGray",
    Default = "default",
    Night = "night",
    CherryBlossomPink = "cherryBlossomPink",
    GamingPurple = "gamingPurple",
    AgateGreen = "agateGreen"
}
export declare enum PaymentElementLayout {
    Tabs = "tabs",
    Accordion = "Accordion"
}
export declare const addressTheme: {
    default: string;
    night: string;
};
export declare enum EventCallbackCode {
    SDK_CREATE_COMPONENT_ERROR = "SDK_CREATE_COMPONENT_ERROR",
    SDK_CREATEPAYMENT_PARAMETER_ERROR = "SDK_CREATEPAYMENT_PARAMETER_ERROR",
    SDK_PAYMENT_ERROR = "SDK_PAYMENT_ERROR",
    SDK_PAYMENT_FAIL = "SDK_PAYMENT_FAIL",
    SDK_PAYMENT_CANCEL = "SDK_PAYMENT_CANCEL",
    SDK_PAYMENT_SUCCESSFUL = "SDK_PAYMENT_SUCCESSFUL",
    SDK_PAYMENT_PROCESSING = "SDK_PAYMENT_PROCESSING"
}
export declare enum ELEMENT_ENVIRONMENT {
    DEV = "DEV",
    TEST = "TEST",
    SIT = "SIT",
    PRE = "PRE",
    PROD = "PROD",
    SANDBOX = "SANDBOX"
}
type ELEMENT_ENVIRONMENT_VALUE = 'dev' | 'test' | 'sit' | 'pre' | 'prod' | 'sandbox';
export type ELEMENT_ENVIRONMENT_TYPE = keyof typeof ELEMENT_ENVIRONMENT | (typeof ELEMENT_ENVIRONMENT)[keyof typeof ELEMENT_ENVIRONMENT] | ELEMENT_ENVIRONMENT_VALUE;
export interface AddressMountComponentsParams {
    configParams?: AddressMountConfig;
    prefillValue: Array<AddressSubmitData>;
    sessionData: string;
    appearance: {
        themeType: string;
    };
    debugProps?: {
        localLink: string;
    };
    elementProps?: {
        elementLink: string;
    };
}
interface BaseMountOptions<T = void> {
    configParams?: T;
    debugProps?: {
        localLink: string;
    };
    elementProps?: {
        elementLink: string;
    };
}
type HideField = 'shippingCountry' | 'shippingName' | 'shippingPhoneNo' | 'shippingRegion' | 'shippingAddress1' | 'shippingZipCode' | 'shippingAddress2';
interface AddressMountConfig {
    /**
     * 是否开启地址联想功能
     * 0 开启
     * 1 关闭
     */
    autoSaveAsDefaultAddress?: boolean;
    /**
     * 隐藏部分地址要素
     */
    hideFields?: Array<HideField>;
}
export interface AddressMountOptions extends BaseMountOptions<AddressMountConfig> {
    type: ElementType.address;
    prefillValue: Array<AddressSubmitData>;
    appearance?: {
        theme?: ThemeType.Default | ThemeType.Night;
    };
}
export interface LinkAuthMountOptions extends BaseMountOptions {
    type: ElementType.auth;
    appearance?: {
        theme?: ThemeType;
    };
}
type ToCamelCase<S extends string> = S extends `${infer First}-${infer Rest}` ? `${First}${Capitalize<ToCamelCase<Rest>>}` : S;
type CompatibleVariables<T extends Record<string, string>> = {
    [K in keyof T as K | ToCamelCase<K & string>]: string;
};
export interface PaymentMountOptions extends BaseMountOptions {
    type: ElementType.payment;
    appearance?: {
        theme?: ThemeType;
        layout?: {
            type: PaymentElementLayout;
        };
        variables?: Partial<CompatibleVariables<{
            'content-primary': string;
            'content-secondary': string;
            'content-tertiary': string;
            'content-quaternary': string;
            'background-primary': string;
            'background-secondary': string;
            'background-disable': string;
            'background-transparency': string;
            'border-primary': string;
            'border-secondary': string;
            'border-disable': string;
            'action-normal': string;
            'action-hover': string;
            'action-disable': string;
            'action-secondary': string;
            'state-failure': string;
            'state-warning': string;
            'state-success': string;
            'state-info': string;
            'state-marketing': string;
            'radius-backup': string;
            'radius-module': string;
            'radius-component': string;
            'radius-button': string;
            'wrapper-padding': string;
            'stroke-default': string;
            'stroke-active': string;
        }>>;
        card?: {
            showBrandIcon?: boolean;
        };
        accordion?: {
            showRadio?: boolean;
        };
    };
    notRedirectAfterComplete?: boolean;
    merchantAppointParam?: IMerchantAppointParam;
}
export declare enum AddressEventCallbackName {
    SHIPPING_CHANGE = "SHIPPING_CHANGE"
}
interface BaseMountResult {
}
export interface AddressMountResult extends BaseMountResult {
    on: (event: AddressEventCallbackName, callback: (data: any) => void) => void;
}
export interface LinkAuthMountResult extends BaseMountResult {
}
export interface PaymentMountResult extends BaseMountResult {
}
/**
 * connect element之间通信的类型格式
 */
export interface ConnectElementMessageDataType<T = {}> {
    source?: ElementPaymentMethod;
    target?: ElementPaymentMethod;
    data?: T;
    event?: ElementPaymentEvent;
}
export interface ValidateResult<T = {}> {
    success: boolean;
    data: {
        success: boolean;
        status: PaymentStatus;
        message?: string;
        data: T;
    };
}
export interface AuthSubmitData {
    accountInfo: {
        email: string;
    };
}
export interface PaymentSubmitData {
    paymentMethod: {
        paymentMethodType: string;
        paymentMethodDetail?: {
            cardNo?: string;
        };
        cardHolderName?: {
            firstName: string;
        };
        lastName: string;
    };
    paymentFactors: {
        paymentRedirectUrl: string;
        paymentMethodId?: string;
    };
}
export interface ShippingInfo {
    shippingName: {
        firstName: string;
        lastName: string;
        middleName?: string;
        fullName?: string;
    };
    shippingPhoneNo: string;
    shippingAddress: {
        region: string;
        address1: string;
        address2: string;
        city?: string;
        state?: string;
        zipCode: string;
    };
}
export interface AddressSubmitData {
    shippingName: {
        firstName: string;
        lastName: string;
    };
    shippingPhoneNo: string;
    shippingAddress: {
        region: string;
        address1: string;
        address2: string;
        city?: string;
        province?: string;
        zipCode: string;
        districts?: string[];
        districtValues?: {
            [key: string]: string;
        };
    };
    notes: string;
    prefer: '1' | '0';
    shippingId: string;
    actionFlag?: 'I' | 'U' | 'D';
}
export interface SubmitFuncParams {
    handleActions?: boolean;
    shippingInfo?: ShippingInfo;
}
export interface SubmitServiceParams extends PaymentSubmitData {
    accountInfo: AuthSubmitData['accountInfo'];
    shipping?: AddressSubmitData;
}
interface SubmitResultActionForm extends ActionForm {
    paymentCodeExpireTime: string;
}
export interface SubmitServiceResult {
    success: boolean;
    errorCode: ConnectErrorCode;
    errorMessage: string;
    errorStatus: string;
    traceId: string;
    actionForm?: SubmitResultActionForm;
    codeFormViews?: Array<{
        codeExpireTime?: string;
    }>;
}
export interface SubmitFuncResult {
    success: boolean;
    msg: string;
}
declare enum AccountStatusEnum {
    EFFECTIVE = "EFFECTIVE",
    UNREGISTERED = "UNREGISTERED"
}
type IAccountInfo = {
    email?: string;
    verifyId?: string;
    accountStatus?: AccountStatusEnum;
    oneAccountId?: string;
    needOtp?: boolean;
    errorMsg?: string;
    inputStatus?: 'success' | 'loading' | 'error' | 'focused' | '';
    resendLeftTimes?: number;
};
interface ShippingsItem {
    shippingName: {
        firstName: string;
        lastName: string;
    };
    prefer: '1' | '0';
    shippingId: string;
    shippingPhoneNo: string;
    shippingAddress: {
        region: string;
        state: string;
        city: string;
        address1: string;
        address2: string;
        zipCode: string;
    };
}
interface Estimate {
    unit: string;
    value: number;
}
interface DeliveryEstimate {
    maximum: Estimate;
    minimum: Estimate;
}
interface FixedAmount {
    amount: number;
    currency: string;
}
interface ShippingRateData {
    displayName: string;
    deliveryEstimate: DeliveryEstimate;
    fixedAmount: FixedAmount;
}
interface ShippingAddress {
    address1: string;
    address2: string;
    city: string;
    region: string;
    state: string;
    zipCode: string;
}
interface IUserName {
    firstName: string;
    middleName?: string;
    lastName: string;
    fullName?: string;
}
type Shippings = ShippingsItem[];
type IPaymentMethods = IPaymentMethod[];
interface CKPShipping {
    shippingRateId?: string;
    shippingRateData?: ShippingRateData;
    shippingAddress: ShippingAddress;
    shippingFee?: IAmount;
    shippingFeeView?: IAmountView;
    shippingDescription?: string;
    deliveryEstimate?: DeliveryEstimate;
    shippingFeeId?: string;
    shippingName?: IUserName;
    shippingPhoneNo?: string;
    shipToEmail?: string;
    notes?: string;
}
export interface AccountQueryRequest {
    paymentSessionData: string;
    paymentSessionConfig: any;
    accountInfo: IAccountInfo;
}
export interface AccountQueryResult {
    accountInfo: IAccountInfo;
    actionForm?: ActionForm;
    paymentMethods: IPaymentMethods;
    shippings: Shippings;
    success: boolean;
    errorCode?: string;
    errorMessage?: string;
    errorStatus?: string;
    shippingInfo?: CKPShipping;
}
export interface IElementOptions {
    sessionData: string;
    environment?: ELEMENT_ENVIRONMENT_TYPE;
    locale?: string;
    version?: string;
    appearance?: {
        theme: ThemeType.Default | ThemeType.Night;
    };
    onEventCallback?: ({ code, message, result }: {
        code: EventCallbackCode;
        message: string;
        result?: any;
    }) => void;
    loading?: {
        onStartLoading: () => void;
        onEndLoading: () => void;
    };
}
export interface IElementProcessors {
    [ElementType.auth]: AuthProcessor;
    [ElementType.address]: AddressProcessor;
    [ElementType.payment]: PaymentProcessor;
}
export interface IToastOptions {
    position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'center';
    backgroundColor?: string;
    color?: string;
    padding?: string;
    borderRadius?: string;
    fontSize?: string;
    zIndex?: number;
    width?: string;
    duration?: number;
    icon?: 'SUCCESS' | 'FAIL';
    spin?: boolean;
}
interface IPaymentSession {
    nextAction: INextAction;
}
interface INextAction {
    normalUrl: string;
    applinkUrl?: string;
    schemeUrl?: string;
}
export interface ICommonApiResponse {
    error?: {
        code: string;
        message: string;
        traceId?: string;
        context?: any;
        needChangeSessionForRetry?: boolean;
    };
}
export interface IPaymentApiResponse extends ICommonApiResponse {
    status: keyof typeof PaymentStatus | '';
    userCanceled3D?: boolean;
    session?: IPaymentSession;
}
export declare class InvalidElementConfigError extends Error {
    errors: Array<{
        field: keyof IElementOptions;
        message: string;
    }>;
    constructor(errors: Array<{
        field: keyof IElementOptions;
        message: string;
    }>);
}
export declare enum EXPOSURE_API_EVENT {
    DESTORY = "destroy",
    MOUNT = "mount",
    SUBMITPAYMENT = "submitPayment",
    VALIDATAFIELDS = "validateFields",
    UPDATEPAYMENT = "updatePayment"
}
export declare enum EVENTNAME {
    PAYMENTMETHODCHANGED = "paymentMethodChanged",
    VALUESCHANGED = "valuesChanged"
}
interface PaymentMethodChangedData {
    type: string;
    name: string;
}
interface ValuesChangedData {
    region: string;
    state: string;
    city: string;
    address1: string;
    address2: string;
    zipCode: string;
    phoneNo: string;
    name: {
        firstName: string;
        lastName: string;
        middleName: string;
    };
}
export interface EventDataMap {
    [EVENTNAME.PAYMENTMETHODCHANGED]: PaymentMethodChangedData;
    [EVENTNAME.VALUESCHANGED]: ValuesChangedData;
}
export {};
