import type { CSSProperties } from 'react';
import type { Root } from 'react-dom/client';

import type { Theme } from './theme';
import type { ZkProofModel } from './zk-proof-model';

export type Props = {
    id: string;
    apiUrl: string;
    elementId: string;
    onFinish?: () => void | Promise<void>;
    getZkProof?: (zkProof: ZkProofModel) => void | Promise<void>;
    onInit?: (
        verificationStatus: 'completed' | 'expired' | 'active' | 'error',
        error?: unknown,
    ) => void | Promise<void>;
    settings?: unknown;
    redirectUrl?: string;
    logsUrl?: string;
    theme?: Theme;
    logo?: string;
    className?: string;
    style?: CSSProperties;
};

export type UpdateStylesOptions = {
    className?: string;
    style?: CSSProperties;
};

export type WidgetInstance = {
    root: Root | null;
    destroy: () => void;
    updateStyles: (options: UpdateStylesOptions) => void;
};

declare module '@document-verification/docver-widget' {
    export type DocsVerificationWidgetProps = Props;
    export type DocsVerificationWidgetInstance = WidgetInstance;
    export const DocsVerificationWidget: (
        props: DocsVerificationWidgetProps,
    ) => DocsVerificationWidgetInstance;
}
