import { jsx as _jsx } from "react/jsx-runtime";
import { DateRangeSeparatedPicker, parseAbsoluteDate } from '@cube-dev/ui-kit';
import { useCallback, useMemo } from 'react';
export function TimeDateRangeSelector(props) {
    const { value, onChange } = props;
    const onChangeHandler = useCallback((val) => {
        onChange([
            val.start.toString().split(/[+\]]/)[0].replace('T00:00:00', ''),
            val.end.toString().split(/[+\]]/)[0].replace('T00:00:00', ''),
        ]);
    }, [onChange]);
    const dateValue = useMemo(() => {
        const startDate = parseAbsoluteDate(value[0]);
        const endDate = parseAbsoluteDate(value[1]);
        return startDate && endDate
            ? {
                start: startDate,
                end: endDate,
            }
            : null;
    }, [value[0], value[1]]);
    return useMemo(() => (_jsx(DateRangeSeparatedPicker, { "aria-label": "Date range picker", size: "small", defaultValue: dateValue, onChange: onChangeHandler })), [onChangeHandler]);
}
//# sourceMappingURL=TimeDateRangeSelector.js.map