import * as React from "react";

export interface ConfirmationResult<T = undefined> {
  confirmed: boolean;
  result: T | undefined;
}

export interface ConfirmationContentProps<TData, TResult = undefined> {
  data: TData | undefined;
  setResult: (result: TResult) => void;
  setIsValid: (isValid: boolean) => void;
  confirm: () => void;
  confirmResult: (result: TResult) => void;
  cancel: () => void;
}

export interface ConfirmationWithResultContentProps<TData, TResult = undefined> {
  data: TData | undefined;
  confirmResult: (result: TResult) => void;
  cancel: () => void;
}

export interface ConfirmationOptions {
  title?: string | undefined;
  showConfirmButton?: boolean | undefined;
  showCancelButton?: boolean | undefined;
  confirmButtonText?: string | undefined;
  cancelButtonText?: string | undefined;
  showCloseButton?: boolean | undefined;
  fullCustomization?: boolean | undefined;
  closeOnOutsideClick?: boolean | undefined;
  state?: "success" | "info" | "alert" | "error";
}

export interface ConfirmComponentUI<TData = undefined, TResult = undefined> {
  component: | React.ComponentType<ConfirmationContentProps<TData, TResult> | ConfirmationWithResultContentProps<TData, TResult>>
  | (new () => HTMLElement);
  styles?: string;
}

export abstract class PrimariaInteractionService {
  abstract confirm<TData = undefined, TResult = undefined>(
    data: TData | undefined,
    componentUI: ConfirmComponentUI<TData, TResult>,
    options?: ConfirmationOptions | undefined,
  ): Promise<ConfirmationResult<TResult | undefined>>;
  abstract confirmMessage(
    message: string,
    options?: ConfirmationOptions | undefined,
  ): Promise<ConfirmationResult>;
  abstract dispose(): void;
}
