import {
    type ViewStyle
} from "react-native";
import {
    type NCoreUIKitIcon
} from "../../types";
import type IBottomSheetProps from "../bottomSheet/type";
import type {
    DayOfWeekLengthType
} from "../dateSelector/type";
import type {
    MonthOfYearLengthType
} from "../monthSelector/type";
import type {
    RRule
} from "rrule";

export type IDateTimePickerRef = {
    setDateRange: (dateRange: DateTimePickerDateRange) => void;
    getValue: () => {
        dateRange?: DateTimePickerDateRange;
        dateRule?: RRule;
        date?: Date;
    };
    setIsLoading: (state: boolean) => void;
    setDateRule: (dateRule: RRule) => void;
    setDate: (date: Date) => void;
    cancel: () => void;
    clean: () => void;
    focus: () => void;
    blur: () => void;
    ok: () => void;
};

export type DateTimePickerDynamicStyleType = {
    inlineSpaces: NCoreUIKit.ActivePalette["inlineSpaces"];
    spreadBehaviour?: DateTimePickerSpreadBehaviour;
    radiuses: NCoreUIKit.ActivePalette["radiuses"];
    spaces: NCoreUIKit.ActivePalette["spaces"];
    colors: NCoreUIKit.ActivePalette["colors"];
    currentType: DateTimePickerTypes;
    borders: NCoreUIKit.Borders;
    type: DateTimePickerType;
    isSearchable?: boolean;
    isDisabled?: boolean;
    isActive: boolean;
    title?: string;
    icon?: boolean;
};

export type DateTimePickerTypes = {
    containerColor: keyof NCoreUIKit.ContainerContentColors;
    focusBorderColor: keyof NCoreUIKit.BorderContentColors;
    hintTextIconColor: keyof NCoreUIKit.IconContentColors;
    placeholderColor: keyof NCoreUIKit.TextContentColors;
    hintTextColor: keyof NCoreUIKit.TextContentColors;
    borderColor: keyof NCoreUIKit.BorderContentColors;
    inputColor: keyof NCoreUIKit.TextContentColors;
    titleColor: keyof NCoreUIKit.TextContentColors;
    iconColor: keyof NCoreUIKit.IconContentColors;
};

export type DateTimePickerType = "default" | "danger" | "warning" | "question" | "success" | "info";

export type DateTimePickerSpreadBehaviour = "baseline" | "stretch" | "free";

export type DateTimePickerPickerType = "date" | "time" | "date-time";

export type DateTimePickerVariant = "single" | "range" | "rrule";

export type DateTimePickerDateRange = {
    start?: Date;
    end?: Date;
};

export type DateTimePickerDateRangeResponse = {
    start?: Date | string;
    end?: Date | string;
};

export type DateCalendarType = "day" | "month" | "year";

export type YearToken = "YYYY" | "YY";

export type MonthToken = "MMMM" | "MMM" | "MM" | "M";

export type DayToken = "dddd" | "ddd" | "DD" | "D";

export type DateTokenCombination = |
    `${YearToken}${Separator}${MonthToken}${Separator}${DayToken}` |
    `${DayToken}${Separator}${MonthToken}${Separator}${YearToken}` |
    `${MonthToken}${Separator}${DayToken}${Separator}${YearToken}`;

export type Separator = "-" | "." | "/" | " ";

export type TimeToken = "HH:mm" | "HH:mm:ss" | "hh:mm a";

export type ValidTitleFormat = DateTokenCombination | `${DateTokenCombination} ${TimeToken}`;

interface IDateTimePickerProps {
    dateRangeTitle?: (dateRange: DateTimePickerDateRange | undefined) => string;
    customDateTimeSheetTheme?: {
        gapPropagation?: keyof NCoreUIKit.GapPropagationKey;
        sharpness?: keyof NCoreUIKit.SharpnessKey;
        paletteKey?: keyof NCoreUIKit.PaletteKey;
        themeKey?: keyof NCoreUIKit.ThemeKey;
    };
    customTheme?: {
        gapPropagation?: keyof NCoreUIKit.GapPropagationKey;
        sharpness?: keyof NCoreUIKit.SharpnessKey;
        paletteKey?: keyof NCoreUIKit.PaletteKey;
        themeKey?: keyof NCoreUIKit.ThemeKey;
    };
    isTimeSelectWorksWithCenterWhenTimePicker?: boolean;
    spreadBehaviour?: DateTimePickerSpreadBehaviour;
    onChange?: (props: {
        dateRange?: DateTimePickerDateRangeResponse,
        date?: Date | string,
        dateRule?: RRule
    }) => void;
    onOk?: (props: {
        dateRange?: DateTimePickerDateRangeResponse,
        date?: Date | string,
        dateRule?: RRule
    }) => void;
    onCancel?: (props: {
        dateRange?: DateTimePickerDateRangeResponse,
        date?: Date | string,
        dateRule?: RRule
    }) => void;
    multipleSelectMinimumRequiredDayCount?: number;
    customDateTimeSheetLocalize?: {
        activeLocale?: keyof NCoreUIKit.LocaleKey;
    };
    customLocalize?: {
        activeLocale?: keyof NCoreUIKit.LocaleKey;
    };
    monthOfYearLengthType?: MonthOfYearLengthType;
    initialDateRange?: DateTimePickerDateRange;
    multipleSelectMinimumRequireMS?: number;
    removeSelectValidation?: (props: {
        dateRange?: DateTimePickerDateRange,
        dateRule?: RRule,
        date?: Date
    }) => boolean;
    selectValidation?: (props: {
        dateRange?: DateTimePickerDateRange,
        dateRule?: RRule,
        date?: Date
    }) => boolean;
    isStartDateSelectionRequired?: boolean;
    dayOfWeekLength?: DayOfWeekLengthType;
    pickerType?: DateTimePickerPickerType;
    isEndDateSelectionRequired?: boolean;
    localeBasedFirstDayOfWeek?: boolean;
    isShowCalenderChangerTool?: boolean;
    dateCalendarType?: DateCalendarType;
    hintTextContainerStyle?: ViewStyle;
    renderLoadingIcon?: NCoreUIKitIcon;
    contentContainerStyle?: ViewStyle;
    multipleSelectMaximumMS?: number;
    multipleSelectDayLimit?: number;
    returnFormat?: ValidTitleFormat;
    variant?: DateTimePickerVariant;
    isShowTodayIndicator?: boolean;
    titleFormat?: ValidTitleFormat;
    isShowDateTimeTools?: boolean;
    hintTextIconStyle?: ViewStyle;
    hintTextIcon?: NCoreUIKitIcon;
    isWorkWithRealtime?: boolean;
    isShowHintTextIcon?: boolean;
    isWorkWithSeconds?: boolean;
    cleanIconStyle?: ViewStyle;
    rightIconStyle?: ViewStyle;
    rightIcon?: NCoreUIKitIcon;
    dateTimeSheetProps?: Omit<
        IBottomSheetProps, |
    "key" |
    "customKey" |
    "ref" |
    "isAutoHeight" |
    "isActive" |
    "renderBottom" |
    "renderHeader" |
    "onClose"
    >;
    type?: DateTimePickerType;
    isShowSubTitle?: boolean;
    isCleanEnabled?: boolean;
    contentStyle?: ViewStyle;
    initialDateRule?: RRule;
    isSearchable?: boolean;
    iconStyle?: ViewStyle;
    icon?: NCoreUIKitIcon;
    placeholder?: string;
    isRequired?: boolean;
    isDisabled?: boolean;
    isOptional?: boolean;
    onFocus?: () => void;
    onBlur?: () => void;
    initialDate?: Date;
    customKey?: string;
    maxChoice?: number;
    minChoice?: number;
    hintText?: string;
    subTitle?: string;
    style?: ViewStyle;
    maxDate?: Date;
    minDate?: Date;
    title?: string;
    id?: string;
};
export type {
    IDateTimePickerProps as default
};
