/** @license MIT | @cube-dev/ui-kit v0.127.1 | Cube Dev Team */
import { _Title } from "../../content/Title.js";
import { useProviderProps } from "../../../provider.js";
import { Space } from "../../layout/Space.js";
import { LeftIcon } from "../../../icons/LeftIcon.js";
import { RightIcon } from "../../../icons/RightIcon.js";
import { Button } from "../../actions/index.js";
import { CalendarGrid } from "./CalendarGrid.js";
import { tasty } from "@tenphi/tasty";
import { forwardRef, useImperativeHandle, useRef } from "react";
import { jsx, jsxs } from "react/jsx-runtime";
import { useLocale, useRangeCalendar } from "react-aria";
import { createDOMRef } from "@react-spectrum/utils";
import { useRangeCalendarState } from "react-stately";
import { createCalendar } from "@internationalized/date";

//#region src/components/other/Calendar/RangeCalendar.tsx
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 /* @__PURE__ */ jsxs(CalendarElement, {
		ref: domRef,
		...calendarProps,
		children: [/* @__PURE__ */ jsxs(CalendarHeaderElement, { children: [/* @__PURE__ */ jsx(_Title, {
			level: 6,
			preset: "h6",
			children: title
		}), /* @__PURE__ */ jsxs(Space, {
			gap: ".5x",
			children: [/* @__PURE__ */ jsx(Button, {
				size: "small",
				...prevButtonProps,
				icon: /* @__PURE__ */ jsx(LeftIcon, {})
			}), /* @__PURE__ */ jsx(Button, {
				size: "small",
				...nextButtonProps,
				icon: /* @__PURE__ */ jsx(RightIcon, {})
			})]
		})] }), /* @__PURE__ */ jsx(CalendarGrid, { state })]
	});
}
const _RangeCalendar = forwardRef(RangeCalendar);
_RangeCalendar.displayName = "RangeCalendar";

//#endregion
export { _RangeCalendar };
//# sourceMappingURL=RangeCalendar.js.map