import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { DatePickerPopover, DEFAULT_DATE_MASK, MinMaxDateContextProvider, PopoverHoveredContextProvider, YearMonthDayPicker, } from '../DatePicker';
import { FormHelperText } from '../FormHelperText';
import { Grid } from '../Grid';
import { PickerSplitter, StyledDatePickerInput, StyledPaper } from './styles';
import { useLogic } from './useLogic';
const DEFAULT_SPACING = 1;
export const DateRangePicker = forwardRef((props, forwardedRef) => {
    const { ref, startDatePickerInputProps, endDatePickerInputProps, popoverHoveredContextProviderProps, datePickerPopoverProps, minMaxDateContextProviderProps, startYearMonthDayPickerProps, endYearMonthDayPickerProps, } = useLogic(props, forwardedRef);
    const { startDateProps = {}, endDateProps = {}, mask = DEFAULT_DATE_MASK, spacing = DEFAULT_SPACING, size, isMondayFirst, isDisabled, isError, helperText, isDoubleNavigationButtonsEnabled, hideHelperText = false, } = props;
    const { inputProps: startDateInputProps, ...restStartDateProps } = startDateProps || {};
    const { inputProps: endDateInputProps, ...restEndDateProps } = endDateProps || {};
    return (_jsxs(Grid, { ref: ref, children: [_jsxs(Grid, { container: true, spacing: spacing, direction: "column", columns: "repeat(2, 1fr)", children: [_jsx(StyledDatePickerInput, { ...startDateInputProps, ...restStartDateProps, 
                        // TODO Пропс margin=none пока не работает, поэтому стилизуем компонент
                        // https://track.astral.ru/soft/browse/UIKIT-1333
                        mask: mask, size: size, disabled: isDisabled, error: isError, ...startDatePickerInputProps }), _jsx(StyledDatePickerInput, { ...endDateInputProps, ...restEndDateProps, size: size, mask: mask, disabled: isDisabled, error: isError, ...endDatePickerInputProps })] }), _jsx(FormHelperText, { error: isError, hideHelperText: hideHelperText, children: helperText && helperText }), _jsx(PopoverHoveredContextProvider, { ...popoverHoveredContextProviderProps, children: _jsx(MinMaxDateContextProvider, { ...minMaxDateContextProviderProps, children: _jsx(DatePickerPopover, { ...datePickerPopoverProps, children: _jsxs(StyledPaper, { children: [_jsx(YearMonthDayPicker, { isMondayFirst: isMondayFirst, isDoubleNavigationButtonsEnabled: isDoubleNavigationButtonsEnabled, ...startYearMonthDayPickerProps }), _jsx(PickerSplitter, {}), _jsx(YearMonthDayPicker, { isMondayFirst: isMondayFirst, isDoubleNavigationButtonsEnabled: isDoubleNavigationButtonsEnabled, ...endYearMonthDayPickerProps })] }) }) }) })] }));
});
