import { DetailedHTMLProps, HTMLAttributes, ReactNode, JSX } from 'react';

type HighlightMode = "word" | "sentence" | "line" | "paragraph";
type PauseReason = "auto" | "manual";
type SpanProps = DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
type SpeakingWord = {
    index: string;
    charIndex: number;
    length: number;
} | null;
type SpeechStatus = "started" | "paused" | "stopped" | "queued";
type SpeechSynthesisErrorHandler = (error: Error) => any;
type SpeechSynthesisEventHandler = (event: SpeechSynthesisEvent) => any;
type SpeechSynthesisEventName = "word" | "sentence";
type SpeechSynthesisUtteranceProps = {
    pitch?: number;
    rate?: number;
    volume?: number;
    lang?: string;
    voiceURI?: string | string[];
};
type UseSpeechOptions = SpeechSynthesisUtteranceProps & {
    text: ReactNode;
    autoPlay?: boolean;
    preserveUtteranceQueue?: boolean;
    highlightText?: boolean;
    showOnlyHighlightedText?: boolean;
    highlightMode?: HighlightMode;
    highlightProps?: SpanProps;
    enableDirectives?: boolean;
    maxChunkSize?: number;
    onError?: SpeechSynthesisErrorHandler;
    onStart?: SpeechSynthesisEventHandler;
    onResume?: SpeechSynthesisEventHandler;
    onPause?: SpeechSynthesisEventHandler;
    onStop?: SpeechSynthesisEventHandler;
    onBoundary?: SpeechSynthesisEventHandler;
    onQueueChange?: QueueChangeEventHandler;
};
type IconProps = DetailedHTMLProps<HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>;
type Button = JSX.Element | string | null;
type Children = (childrenOptions: ChildrenOptions) => ReactNode;
type ChildrenOptions = {
    speechStatus?: SpeechStatus;
    isInQueue?: boolean;
    start?: Function;
    pause?: Function;
    stop?: Function;
};
type DivProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>;
type SpeechProps = UseSpeechOptions & {
    id?: string;
    startBtn?: Button;
    pauseBtn?: Button;
    stopBtn?: Button;
    useStopOverPause?: boolean;
    props?: DivProps;
    children?: Children;
};
type QueueChangeEventHandler = (queue: SpeechUtterancesQueue) => any;
type SpeechQueueItem = {
    text: string;
    utterance: SpeechSynthesisUtterance;
    setSpeechStatus: SpeechStatusUpdater;
};
type SpeechQueue = SpeechQueueItem[];
type SpeechStatusUpdater = (newStatus: SpeechStatus) => void;
type SpeechUtterancesQueue = Partial<SpeechSynthesisUtterance>[];
type Index = string | number;
type State = {
    stopReason: PauseReason | "change";
};
type Words = string | Words[];

export type { Button, Children, ChildrenOptions, DivProps, HighlightMode, IconProps, Index, PauseReason, QueueChangeEventHandler, SpanProps, SpeakingWord, SpeechProps, SpeechQueue, SpeechQueueItem, SpeechStatus, SpeechStatusUpdater, SpeechSynthesisErrorHandler, SpeechSynthesisEventHandler, SpeechSynthesisEventName, SpeechSynthesisUtteranceProps, SpeechUtterancesQueue, State, UseSpeechOptions, Words };
