/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.98.7
 * Released under the MIT license.
 */

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { createCalendar } from '@internationalized/date';
import { createDOMRef } from '@react-spectrum/utils';
import { forwardRef, useImperativeHandle, useRef } from 'react';
import { useLocale, useRangeCalendar, } from 'react-aria';
import { useRangeCalendarState } from 'react-stately';
import { LeftIcon, RightIcon } from '../../../icons';
import { useProviderProps } from '../../../provider';
import { tasty } from '../../../tasty';
import { Button } from '../../actions';
import { Title } from '../../content/Title';
import { Space } from '../../layout/Space';
import { CalendarGrid } from './CalendarGrid';
const CalendarElement = tasty({
    styles: {
        padding: '1x',
        gap: '1x',
    },
});
const CalendarHeaderElement = tasty({
    styles: {
        display: 'flex',
        placeContent: 'center space-between',
        placeItems: 'center',
        gap: '1.5x',
    },
});
function RangeCalendar(props, ref) {
    props = useProviderProps(props);
    let { locale } = useLocale();
    let state = useRangeCalendarState({
        ...props,
        locale,
        createCalendar,
    });
    let domRef = useRef(null);
    useImperativeHandle(ref, () => ({
        ...createDOMRef(domRef),
        focus() {
            state.setFocused(true);
        },
    }));
    let { calendarProps, prevButtonProps, nextButtonProps, title } = useRangeCalendar(props, state, domRef);
    return (_jsxs(CalendarElement, { ref: domRef, ...calendarProps, children: [_jsxs(CalendarHeaderElement, { children: [_jsx(Title, { level: 6, preset: "h6", children: title }), _jsxs(Space, { gap: ".5x", children: [_jsx(Button, { size: "small", ...prevButtonProps, icon: _jsx(LeftIcon, {}) }), _jsx(Button, { size: "small", ...nextButtonProps, icon: _jsx(RightIcon, {}) })] })] }), _jsx(CalendarGrid, { state: state })] }));
}
const _RangeCalendar = forwardRef(RangeCalendar);
_RangeCalendar.displayName = 'RangeCalendar';
export { _RangeCalendar as RangeCalendar };

        