import * as React from "react";
import {Alert} from './popups/Alert';
import {Confirm} from './popups/Confirm';

type AriaLiveValues = 'off' | 'polite' | 'assertive' | 'rude';

type NotificationRequiredParams = {
    messageText: React.ReactNode;
}

// See https://stackoverflow.com/questions/43230765/typescript-react-access-component-property-types
type GetComponentProps<T> = T extends React.ComponentType<infer P> | React.Component<infer P> ? P : never

export function showPopup<C = React.ReactNode>(componentOrElement: C, props?: GetComponentProps<C>, popupContext?: object): void;
export function closePopup(): void;
export function showAlert(params: string | GetComponentProps<Alert>): void;
export function showConfirmation(params: GetComponentProps<Confirm>): void;
export function showNotification<C = React.ReactNode>(componentOrElement: C, props: GetComponentProps<C>): void;
export function showNotification(componentOrElement: string, props?: string): void;
export function showNotification<P extends object>(componentOrElement: NotificationRequiredParams & P): void;
export function playMessage(messageText: string, politenessSetting: AriaLiveValues): void;
export function getElementHeight(element: Node, withMargin: boolean): void;
export function scrollToTop(): void;
export function getScrollbarWidth(): number;