import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { DEFAULT_DATE_MASK } from './constants';
import { DatePickerInput } from './DatePickerInput';
import { DatePickerPopover } from './DatePickerPopover';
import { DEFAULT_MAX_DATE, DEFAULT_MIN_DATE, MinMaxDateContextProvider, } from './MinMaxDateContext';
import { ButtonWrapper, ConfirmButton, StyledPaper } from './styles';
import { useLogic } from './useLogic';
import { YearMonthDayPicker } from './YearMonthDayPicker';
export const DatePicker = forwardRef((props, forwardedRef) => {
    const { ref, pickerProps, handleOpen, onAccept, confirmButtonProps, isMobile, DatePickerInputProps, datePickerProps, } = useLogic({ ...props, forwardedRef });
    const { className, startAdornment, label, required, helperText, inputProps, mask = DEFAULT_DATE_MASK, size, disabled, inputRef, minDate = DEFAULT_MIN_DATE, maxDate = DEFAULT_MAX_DATE, isMondayFirst, isDoubleNavigationButtonsEnabled, hideHelperText = false, } = props;
    return (_jsxs("div", { ref: ref, className: className, children: [_jsx(DatePickerInput, { startAdornment: startAdornment, label: label, required: required, helperText: helperText, ...inputProps, ...DatePickerInputProps, onAccept: onAccept, mask: mask, size: size, disabled: disabled, ref: inputRef, onClick: handleOpen, hideHelperText: hideHelperText }), _jsx(DatePickerPopover, { placement: "bottom-start", ...datePickerProps, children: _jsx(MinMaxDateContextProvider, { minDate: minDate, maxDate: maxDate, children: _jsxs(StyledPaper, { children: [_jsx(YearMonthDayPicker, { isMondayFirst: isMondayFirst, isDoubleNavigationButtonsEnabled: isDoubleNavigationButtonsEnabled, ...pickerProps }), isMobile && (_jsx(ButtonWrapper, { children: _jsx(ConfirmButton, { ...confirmButtonProps, size: "large" }) }))] }) }) })] }));
});
