import "./Calendar.css";
import {ActionButton as $da878a05ab4a403e$export$cfc7921d29ef7b80} from "./ActionButton.mjs";
import $5c3fed25abf344cc$export$2e2bcd8739ae039 from "../../icons/ChevronLeft.mjs";
import $04f4b15c8c66bb2a$export$2e2bcd8739ae039 from "../../icons/ChevronRight.mjs";
import {Header as $8e847109a6ab556d$export$8b251419efc915eb, HeaderContext as $8e847109a6ab556d$export$e0e4026c12a8bdbb, Heading as $8e847109a6ab556d$export$a8a3e93435678ff9, HeadingContext as $8e847109a6ab556d$export$d688439359537581} from "./Content.mjs";
import {helpTextStyles as $9afd80978c252040$export$13b1fd5431595bf6} from "./Field.mjs";
import $gwkOZ$intlStringsmjs from "./intlStrings.mjs";
import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../../icons/useSpectrumContextProps.mjs";
import {jsx as $gwkOZ$jsx, jsxs as $gwkOZ$jsxs, Fragment as $gwkOZ$Fragment} from "react/jsx-runtime";
import {Calendar as $gwkOZ$Calendar, CalendarContext as $gwkOZ$CalendarContext, CalendarGrid as $gwkOZ$CalendarGrid, CalendarGridHeader as $gwkOZ$CalendarGridHeader, CalendarGridBody as $gwkOZ$CalendarGridBody, CalendarStateContext as $gwkOZ$CalendarStateContext, CalendarHeaderCell as $gwkOZ$CalendarHeaderCell, CalendarCell as $gwkOZ$CalendarCell} from "react-aria-components/Calendar";
import {getDayOfWeek as $gwkOZ$getDayOfWeek, startOfMonth as $gwkOZ$startOfMonth} from "@internationalized/date";
import {Provider as $gwkOZ$Provider, useSlottedContext as $gwkOZ$useSlottedContext} from "react-aria-components/slots";
import {RangeCalendarContext as $gwkOZ$RangeCalendarContext, RangeCalendarStateContext as $gwkOZ$RangeCalendarStateContext} from "react-aria-components/RangeCalendar";
import {createContext as $gwkOZ$createContext, forwardRef as $gwkOZ$forwardRef, useContext as $gwkOZ$useContext, useMemo as $gwkOZ$useMemo, Fragment as $gwkOZ$Fragment1, useRef as $gwkOZ$useRef} from "react";
import {Text as $gwkOZ$Text} from "react-aria-components/Text";
import {useDateFormatter as $gwkOZ$useDateFormatter} from "react-aria/useDateFormatter";
import {useLocale as $gwkOZ$useLocale} from "react-aria/I18nProvider";
import {useLocalizedStringFormatter as $gwkOZ$useLocalizedStringFormatter} from "react-aria/useLocalizedStringFormatter";


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}
/*
 * Copyright 2024 Adobe. All rights reserved.
 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy
 * of the License at http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under
 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
 * OF ANY KIND, either express or implied. See the License for the specific language
 * governing permissions and limitations under the License.
 */ 

















const $f06f4d5597ad704c$export$3b805cea1f178355 = /*#__PURE__*/ (0, $gwkOZ$createContext)(null);
const $f06f4d5597ad704c$var$calendarStyles = function anonymous(props, overrides) {
    let rules = " ";
    let width = false;
    let maxWidth = false;
    let matches = String(overrides || '').matchAll(/(?:^|\s)(J|G|I|H|_u|_v|_s|__A|_d|_J|z|y|B|A|_P|_9|W|_l|_A|_z|_6|Z|N|L)[^\s]+/g);
    for (let p of matches){
        if (p[1] === "Z") width = true;
        if (p[1] === "L") maxWidth = true;
        rules += p[0];
    }
    rules += ' sd12';
    if (props.isMultiMonth) rules += ' -_4DHzJc-e4mUs12';
    else rules += ' -_4DHzJc-0u6p5b12';
    rules += ' _ta12';
    rules += ' Uj12';
    rules += ' qj12';
    rules += ' __ca12';
    rules += ' -uq4sQ-Sp12';
    rules += ' -LnVzy-ZC12';
    if (props.isMultiMonth) rules += ' -cYDWLb-ZFFQGNb12';
    else rules += ' -cYDWLb-ZnqRBTd12';
    if (props.isMultiMonth) {
        if (!width) rules += ' ZJ12';
    } else if (!width) rules += ' ZRqDA2c12';
    if (props.isMultiMonth) {
        if (!maxWidth) rules += ' Le4mUs12';
    } else if (!maxWidth) rules += ' La12';
    return rules;
};
const $f06f4d5597ad704c$var$headerStyles = " sd12 eb12 _Ce12";
const $f06f4d5597ad704c$var$headingStyles = " sd12 eb12 _Ce12 Jy12 Gy12 Iy12 Hy12 _ub12";
const $f06f4d5597ad704c$var$titleStyles = " uk12 ucJ9TBTb12 ud3Euai12 uea12 ugb12 uhd12 uje12 u2NhKxcl12 uic12 -_6BNtrc-e12 vx12 xd12 _xa12 xX0cczbc12 _xX0cczba12 xfd12 _xfa12 xfX0cczbc12 _xfX0cczba12 _Fd12 _FnuYUweb12 po12 _Wa12 _ub12 _va12";
const $f06f4d5597ad704c$var$headerCellStyles = " uk12 ucJ9TBTb12 ud3Euai12 uea12 ugb12 uhd12 uje12 u2NhKxcl12 uic12 -_6BNtrc-c12 vx12 xd12 _xa12 xX0cczbc12 _xX0cczba12 xfd12 _xfa12 xfX0cczbc12 _xfX0cczba12 _Fd12 _FnuYUweb12 po12 ri12 _Wa12 Sp12 Sbd12 Rp12 Rkd12 Qe12";
const $f06f4d5597ad704c$var$cellStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Le12';
    rules += ' _ob12';
    if (props.isFirstChild) rules += ' Sd12';
    else rules += ' Sp12';
    if (props.isLastChild) rules += ' Rd12';
    else rules += ' Rp12';
    if (props.isFirstWeek) rules += ' Td12';
    else rules += ' Tj12';
    if (props.isLastWeek) rules += ' Qd12';
    else rules += ' Qj12';
    rules += ' _Pc12';
    if (props.isOutsideMonth) rules += ' sk12';
    else rules += ' sd12';
    rules += ' eb12';
    rules += ' _Ca12';
    rules += ' __ca12';
    rules += ' Z0q26ub12';
    rules += ' fa12';
    rules += ' Fd12';
    return rules;
};
const $f06f4d5597ad704c$var$cellInnerStyles = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' Oh12';
    rules += ' Olc12';
    rules += ' _Mc12';
    if (props.isSelectionEnd) rules += ' _Kd12';
    else if (props.isSelectionStart) rules += ' _Kd12';
    else if (props.isSelected) {
        if (props.selectionMode === "range") rules += ' _Kb12';
        else if (props.selectionMode === "single") rules += ' _Kd12';
    } else rules += ' _Kb12';
    rules += ' Yd12';
    rules += ' Yle12';
    rules += ' Xb12';
    rules += ' Xlb12';
    rules += ' _2b12';
    rules += ' _2lb12';
    rules += ' _Pc12';
    rules += ' uk12';
    rules += ' ucJ9TBTb12';
    rules += ' ud3Euai12';
    rules += ' uea12';
    rules += ' ugb12';
    rules += ' uhd12';
    rules += ' uje12';
    rules += ' u2NhKxcl12';
    rules += ' uic12';
    rules += ' -_6BNtrc-c12';
    rules += ' vx12';
    rules += ' xb12';
    rules += ' _xa12';
    rules += ' _Fb12';
    rules += ' _FnuYUwec12';
    if (props.isDisabled) rules += ' pp12';
    else if (props.isSelectionEnd) rules += ' px12';
    else if (props.isSelectionStart) rules += ' px12';
    else if (props.isSelected) {
        if (props.selectionMode === "range") rules += ' pt12';
        else rules += ' px12';
    } else rules += ' pt12';
    if (props.isDisabled) rules += ' plc12';
    else if (props.isSelectionEnd) rules += ' ple12';
    else if (props.isSelectionStart) rules += ' ple12';
    else if (props.isSelected) rules += ' ple12';
    else rules += ' plb12';
    rules += ' ri12';
    rules += ' Za12';
    rules += ' Fb12';
    rules += ' og12';
    rules += ' ng12';
    rules += ' kg12';
    rules += ' jg12';
    rules += ' sd12';
    rules += ' eb12';
    rules += ' _Ca12';
    rules += ' _yb12';
    if (props.isSelectionEnd) {
        if (props.isInvalid) {
            if (props.isFocusVisible) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else if (props.isPressed) rules += ' gYvV9s12';
            else if (props.isHovered) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else rules += ' g7aei812';
        } else if (props.isDisabled) rules += ' g912';
        else if (props.isFocusVisible) rules += ' gUgARdd12';
        else if (props.isPressed) rules += ' gUgARdd12';
        else if (props.isHovered) rules += ' gUgARdd12';
        else rules += ' g5qAiPc12';
    } else if (props.isSelectionStart) {
        if (props.isInvalid) {
            if (props.isFocusVisible) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else if (props.isPressed) rules += ' gYvV9s12';
            else if (props.isHovered) {
                if (props.isUnavailable) rules += ' g7aei812';
                else rules += ' gYvV9s12';
            } else rules += ' g7aei812';
        } else if (props.isDisabled) rules += ' g912';
        else if (props.isFocusVisible) rules += ' gUgARdd12';
        else if (props.isPressed) rules += ' gUgARdd12';
        else if (props.isHovered) rules += ' gUgARdd12';
        else rules += ' g5qAiPc12';
    } else if (props.isSelected) {
        if (props.selectionMode === "range") {
            if (props.isHovered) {
                if (props.isInvalid) {
                    if (props.isUnavailable) rules += ' g912';
                    else rules += ' gJj9Tpd12';
                } else rules += ' gNAacne12';
            }
        } else if (props.selectionMode === "single") {
            if (props.isInvalid) {
                if (props.isFocusVisible) rules += ' gYvV9s12';
                else if (props.isPressed) rules += ' gYvV9s12';
                else if (props.isHovered) rules += ' gYvV9s12';
                else rules += ' g7aei812';
            } else if (props.isDisabled) rules += ' g912';
            else if (props.isFocusVisible) rules += ' gUgARdd12';
            else if (props.isPressed) rules += ' gUgARdd12';
            else if (props.isHovered) rules += ' gUgARdd12';
            else rules += ' g5qAiPc12';
        }
    } else if (props.isDisabled) rules += ' g912';
    else if (props.isPressed) rules += ' gH12';
    else if (props.isHovered) {
        if (props.isUnavailable) rules += ' g912';
        else rules += ' gH12';
    } else rules += ' g912';
    if (props.isUnavailable) rules += ' gl912';
    else if (props.isSelectionEnd) rules += ' gle12';
    else if (props.isSelectionStart) rules += ' gle12';
    else if (props.isSelected) {
        if (props.selectionMode === "range") {
            if (props.isHovered) rules += ' gle12';
        } else if (props.selectionMode === "single") rules += ' gle12';
    } else if (props.isHovered) rules += ' gle12';
    else rules += ' gl912';
    return rules;
};
const $f06f4d5597ad704c$var$todayStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Pa12';
    rules += ' _lakDin12';
    rules += ' _EF12';
    rules += ' _ZRWeLS12';
    rules += ' ZS16uu12';
    rules += ' Fe12';
    rules += ' og12';
    rules += ' ng12';
    rules += ' kg12';
    rules += ' jg12';
    rules += ' g5ZbAob12';
    if (props.isToday) rules += ' sb12';
    else rules += ' sk12';
    return rules;
};
const $f06f4d5597ad704c$var$unavailableStyles = " _Pa12 WzErnCb12 _EjhYzGc12 _RjhYzGc12 FlAZvq12 _ZN7ydnb12 og12 ng12 kg12 jg12 g5ZbAob12";
const $f06f4d5597ad704c$var$selectionBackgroundStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Pa12';
    rules += ' _9a12';
    rules += ' Wr12';
    if (props.isPreviousDayNotSelected) rules += ' _Ar12';
    else if (props.isSelectionStart) rules += ' _Ar12';
    else if (props.isFirstDayInWeek) rules += ' _Ar12';
    else rules += ' _Al12';
    if (props.isNextDayNotSelected) rules += ' _zr12';
    else if (props.isSelectionEnd) rules += ' _zr12';
    else if (props.isLastDayInWeek) rules += ' _zr12';
    else rules += ' _zl12';
    rules += ' _lr12';
    if (props.isPreviousDayNotSelected) rules += ' og12';
    else if (props.isSelectionStart) rules += ' og12';
    else if (props.isFirstDayInWeek) rules += ' og12';
    else rules += ' od12';
    if (props.isPreviousDayNotSelected) rules += ' kg12';
    else if (props.isSelectionStart) rules += ' kg12';
    else if (props.isFirstDayInWeek) rules += ' kg12';
    else rules += ' kd12';
    if (props.isNextDayNotSelected) rules += ' ng12';
    else if (props.isSelectionEnd) rules += ' ng12';
    else if (props.isLastDayInWeek) rules += ' ng12';
    else rules += ' nd12';
    if (props.isNextDayNotSelected) rules += ' jg12';
    else if (props.isSelectionEnd) rules += ' jg12';
    else if (props.isLastDayInWeek) rules += ' jg12';
    else rules += ' jd12';
    if (props.isInvalid) rules += ' gZbQnx12';
    else rules += ' gG12';
    rules += ' gle12';
    rules += ' _yb12';
    return rules;
};
const $f06f4d5597ad704c$var$selectionBorderStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Pa12';
    rules += ' _9c12';
    rules += ' Wr12';
    if (props.isPreviousDayNotSelected) rules += ' _Ar12';
    else if (props.isSelectionStart) rules += ' _Ar12';
    else if (props.isFirstDayInWeek) rules += ' _Ar12';
    else rules += ' _Al12';
    if (props.isNextDayNotSelected) rules += ' _zr12';
    else if (props.isSelectionEnd) rules += ' _zr12';
    else if (props.isLastDayInWeek) rules += ' _zr12';
    else rules += ' _zl12';
    rules += ' _lr12';
    if (props.isPreviousDayNotSelected) rules += ' mb12';
    else if (props.isSelectionStart) rules += ' mb12';
    else if (props.isFirstDayInWeek) rules += ' mb12';
    else rules += ' ma12';
    rules += ' _kb12';
    if (props.isNextDayNotSelected) rules += ' lb12';
    else if (props.isSelectionEnd) rules += ' lb12';
    else if (props.isLastDayInWeek) rules += ' lb12';
    else rules += ' la12';
    rules += ' hb12';
    rules += ' _jf12';
    if (props.isInvalid) rules += ' ip12';
    else rules += ' ix12';
    rules += ' ilb12';
    if (props.isPreviousDayNotSelected) rules += ' og12';
    else if (props.isSelectionStart) rules += ' og12';
    else if (props.isFirstDayInWeek) rules += ' og12';
    else rules += ' od12';
    if (props.isPreviousDayNotSelected) rules += ' kg12';
    else if (props.isSelectionStart) rules += ' kg12';
    else if (props.isFirstDayInWeek) rules += ' kg12';
    else rules += ' kd12';
    if (props.isNextDayNotSelected) rules += ' ng12';
    else if (props.isSelectionEnd) rules += ' ng12';
    else if (props.isLastDayInWeek) rules += ' ng12';
    else rules += ' nd12';
    if (props.isNextDayNotSelected) rules += ' jg12';
    else if (props.isSelectionEnd) rules += ' jg12';
    else if (props.isLastDayInWeek) rules += ' jg12';
    else rules += ' jd12';
    return rules;
};
const $f06f4d5597ad704c$export$e1aef45b828286de = /*#__PURE__*/ (0, $gwkOZ$forwardRef)(function Calendar(props, ref) {
    [props, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props, ref, $f06f4d5597ad704c$export$3b805cea1f178355);
    let { visibleMonths: visibleMonths = 1, errorMessage: errorMessage, UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className, styles: styles, ...otherProps } = props;
    let stringFormatter = (0, $gwkOZ$useLocalizedStringFormatter)((0, ($parcel$interopDefault($gwkOZ$intlStringsmjs))), '@react-spectrum/s2');
    let isMultiMonth = visibleMonths > 1;
    return /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$Calendar), {
        ...otherProps,
        ref: ref,
        visibleDuration: {
            months: visibleMonths
        },
        style: UNSAFE_style,
        className: (UNSAFE_className || '') + $f06f4d5597ad704c$var$calendarStyles({
            isMultiMonth: isMultiMonth
        }, styles),
        children: ({ isInvalid: isInvalid, isDisabled: isDisabled })=>{
            return /*#__PURE__*/ (0, $gwkOZ$jsxs)((0, $gwkOZ$Fragment), {
                children: [
                    /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$Provider), {
                        values: [
                            [
                                (0, $8e847109a6ab556d$export$e0e4026c12a8bdbb),
                                null
                            ],
                            [
                                (0, $8e847109a6ab556d$export$d688439359537581),
                                null
                            ]
                        ],
                        children: /*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$export$9c75275274db0b56, {})
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: " sd12 _tc12 Uj12 qj12 Za12 ed12",
                        children: Array.from({
                            length: visibleMonths
                        }).map((_, i)=>/*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$export$5bd780d491cfc46c, {
                                months: i
                            }, i))
                    }),
                    isInvalid && /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$Text), {
                        slot: "errorMessage",
                        className: (0, $9afd80978c252040$export$13b1fd5431595bf6)({
                            isInvalid: isInvalid,
                            isDisabled: isDisabled,
                            size: 'M'
                        }),
                        children: errorMessage || stringFormatter.format('calendar.invalidSelection', {
                            selectedCount: 1
                        })
                    })
                ]
            });
        }
    });
});
const $f06f4d5597ad704c$export$9c75275274db0b56 = ()=>{
    return /*#__PURE__*/ (0, $gwkOZ$jsxs)((0, $8e847109a6ab556d$export$8b251419efc915eb), {
        styles: $f06f4d5597ad704c$var$headerStyles,
        children: [
            /*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$export$adb29da0ac001538, {
                slot: "previous",
                children: /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $5c3fed25abf344cc$export$2e2bcd8739ae039), {})
            }),
            /*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$var$CalendarHeading, {}),
            /*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$export$adb29da0ac001538, {
                slot: "next",
                children: /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $04f4b15c8c66bb2a$export$2e2bcd8739ae039), {})
            })
        ]
    });
};
const $f06f4d5597ad704c$export$5bd780d491cfc46c = (props)=>{
    let rangeCalendarProps = (0, $gwkOZ$useSlottedContext)((0, $gwkOZ$RangeCalendarContext));
    let calendarProps = (0, $gwkOZ$useSlottedContext)((0, $gwkOZ$CalendarContext));
    let firstDayOfWeek = rangeCalendarProps?.firstDayOfWeek ?? calendarProps?.firstDayOfWeek;
    // use isolation to start a new stacking context so that we can use zIndex -1 for the selection span.
    return /*#__PURE__*/ (0, $gwkOZ$jsxs)((0, $gwkOZ$CalendarGrid), {
        className: " __na12 __oe12 _Bb12",
        offset: {
            months: props.months
        },
        children: [
            /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$CalendarGridHeader), {
                className: "",
                children: (day)=>/*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$var$CalendarHeaderCell, {
                        children: day
                    })
            }),
            /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$CalendarGridBody), {
                className: "",
                children: (date)=>/*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$var$CalendarCell, {
                        date: date,
                        firstDayOfWeek: firstDayOfWeek
                    })
            })
        ]
    });
};
// Ordinarily the heading is a formatted date range, ie January 2025 - February 2025.
// However, we want to show each month individually.
const $f06f4d5597ad704c$var$CalendarHeading = ()=>{
    let calendarStateContext = (0, $gwkOZ$useContext)((0, $gwkOZ$CalendarStateContext));
    let rangeCalendarStateContext = (0, $gwkOZ$useContext)((0, $gwkOZ$RangeCalendarStateContext));
    let { visibleRange: visibleRange, timeZone: timeZone } = calendarStateContext ?? rangeCalendarStateContext ?? {};
    let currentMonth = visibleRange?.start ?? visibleRange?.end;
    let monthFormatter = (0, $gwkOZ$useDateFormatter)({
        month: 'long',
        year: 'numeric',
        era: currentMonth && currentMonth.calendar.identifier === 'gregory' && currentMonth.era === 'BC' ? 'short' : undefined,
        calendar: visibleRange?.start.calendar.identifier,
        timeZone: timeZone
    });
    let months = (0, $gwkOZ$useMemo)(()=>{
        if (!visibleRange) return [];
        let months = [];
        for(let i = visibleRange.start; i.compare(visibleRange.end) <= 0; i = i.add({
            months: 1
        })){
            // TODO: account for the first week possibly overlapping, like with a custom 454 calendar.
            // there has to be a better way to do this...
            if (i.month === visibleRange.start.month) i = i.add({
                weeks: 1
            });
            months.push(monthFormatter.format(i.toDate(timeZone)));
        }
        return months;
    }, [
        visibleRange,
        monthFormatter,
        timeZone
    ]);
    return /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $8e847109a6ab556d$export$a8a3e93435678ff9), {
        styles: $f06f4d5597ad704c$var$headingStyles,
        children: months.map((month, i)=>{
            if (i === 0) return /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$Fragment1), {
                children: /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                    className: $f06f4d5597ad704c$var$titleStyles,
                    children: month
                })
            }, month);
            else return /*#__PURE__*/ (0, $gwkOZ$jsxs)((0, $gwkOZ$Fragment1), {
                children: [
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: " _6b12 ZC12"
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: " _6b12 Zo12"
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: " _6b12 ZC12"
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: $f06f4d5597ad704c$var$titleStyles,
                        children: month
                    })
                ]
            }, month);
        })
    });
};
const $f06f4d5597ad704c$export$adb29da0ac001538 = (props1)=>{
    let { direction: direction } = (0, $gwkOZ$useLocale)();
    return /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
        className: function anonymous(props) {
            let rules = " ";
            if (props.direction === "rtl") {
                rules += ' -Z4Pn4c-a12';
                rules += ' __Ha12';
            }
            if (props.direction === "rtl") {
                rules += ' -_04Pn4c-a12';
                rules += ' __Ha12';
            }
            return rules;
        }({
            direction: direction
        }),
        children: /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $da878a05ab4a403e$export$cfc7921d29ef7b80), {
            ...props1,
            isQuiet: true,
            children: props1.children
        })
    });
};
const $f06f4d5597ad704c$var$CalendarHeaderCell = (props)=>{
    return /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$CalendarHeaderCell), {
        className: $f06f4d5597ad704c$var$headerCellStyles,
        children: props.children
    });
};
const $f06f4d5597ad704c$var$CalendarCell = (props)=>{
    let { locale: locale } = (0, $gwkOZ$useLocale)();
    let firstDayOfWeek = props.firstDayOfWeek;
    // Calculate the day and week index based on the date.
    let { dayIndex: dayIndex, weekIndex: weekIndex, lastWeekIndex: lastWeekIndex } = $f06f4d5597ad704c$var$useWeekAndDayIndices(props.date, locale, firstDayOfWeek);
    let calendarStateContext = (0, $gwkOZ$useContext)((0, $gwkOZ$CalendarStateContext));
    let rangeCalendarStateContext = (0, $gwkOZ$useContext)((0, $gwkOZ$RangeCalendarStateContext));
    let state = calendarStateContext ?? rangeCalendarStateContext;
    let isFirstWeek = weekIndex === 0;
    let isLastWeek = weekIndex === lastWeekIndex;
    let isFirstChild = dayIndex === 0;
    let isLastChild = dayIndex === 6;
    return /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$CalendarCell), {
        date: props.date,
        className: (renderProps)=>$f06f4d5597ad704c$var$cellStyles({
                ...renderProps,
                isFirstChild: isFirstChild,
                isLastChild: isLastChild,
                isFirstWeek: isFirstWeek,
                isLastWeek: isLastWeek
            }),
        children: (renderProps)=>/*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$var$CalendarCellInner, {
                ...props,
                weekIndex: weekIndex,
                dayIndex: dayIndex,
                state: state,
                isRangeSelection: !!rangeCalendarStateContext,
                renderProps: renderProps
            })
    });
};
const $f06f4d5597ad704c$var$CalendarCellInner = (props)=>{
    let { dayIndex: dayIndex, date: date, renderProps: renderProps, state: state, isRangeSelection: isRangeSelection } = props;
    let ref = (0, $gwkOZ$useRef)(null);
    let { isUnavailable: isUnavailable, formattedDate: formattedDate, isSelected: isSelected, isSelectionStart: isSelectionStart, isSelectionEnd: isSelectionEnd, isInvalid: isInvalid } = renderProps;
    // only apply the selection start/end styles if the start/end date is actually selectable (aka not unavailable)
    // or if the range is invalid and thus we still want to show the styles even if the start/end date is an unavailable one
    isSelectionStart = isSelectionStart && (!isUnavailable || isInvalid);
    isSelectionEnd = isSelectionEnd && (!isUnavailable || isInvalid);
    let isDateInRange = (checkDate)=>{
        if (!('highlightedRange' in state) || !state.highlightedRange) return state.isSelected(checkDate);
        // if invalid, check if date is within the full range boundaries
        if (isInvalid) return checkDate.compare(state.highlightedRange.start) >= 0 && checkDate.compare(state.highlightedRange.end) <= 0;
        return state.isSelected(checkDate);
    };
    let prevDay = date.subtract({
        days: 1
    });
    let nextDay = date.add({
        days: 1
    });
    let isFirstDayInWeek = dayIndex === 0;
    let isLastDayInWeek = dayIndex === 6;
    let isPreviousDayNotSelected = !prevDay || !isDateInRange(prevDay) || prevDay.month !== props.date.month;
    let isNextDayNotSelected = !nextDay || !isDateInRange(nextDay) || nextDay.month !== props.date.month;
    // when invalid, show background for all selected dates (including unavailable) to make continuous range appearance
    // when valid, only show background for available selected dates
    let isBackgroundStyleApplied = isSelected && isRangeSelection && (isInvalid || !isUnavailable) && (isDateInRange(prevDay) || nextDay.month === date.month && isDateInRange(nextDay));
    return /*#__PURE__*/ (0, $gwkOZ$jsxs)("div", {
        className: " _Pc12 Za12 Fb12",
        children: [
            /*#__PURE__*/ (0, $gwkOZ$jsxs)("div", {
                ref: ref,
                style: (0, $10ea7662e51a285b$export$56e8cba416805d8d)(ref, {})(renderProps),
                className: $f06f4d5597ad704c$var$cellInnerStyles({
                    ...renderProps,
                    isSelectionStart: isSelectionStart,
                    isSelectionEnd: isSelectionEnd,
                    selectionMode: isRangeSelection ? 'range' : 'single'
                }),
                children: [
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: $f06f4d5597ad704c$var$todayStyles(renderProps),
                        role: "presentation"
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        children: formattedDate
                    }),
                    isUnavailable && /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: $f06f4d5597ad704c$var$unavailableStyles,
                        role: "presentation"
                    })
                ]
            }),
            isBackgroundStyleApplied && /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                className: $f06f4d5597ad704c$var$selectionBackgroundStyles({
                    isInvalid: isInvalid,
                    isFirstDayInWeek: isFirstDayInWeek,
                    isLastDayInWeek: isLastDayInWeek,
                    isSelectionStart: isSelectionStart,
                    isSelectionEnd: isSelectionEnd,
                    isPreviousDayNotSelected: isPreviousDayNotSelected,
                    isNextDayNotSelected: isNextDayNotSelected
                }),
                role: "presentation"
            }),
            isBackgroundStyleApplied && /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                className: $f06f4d5597ad704c$var$selectionBorderStyles({
                    isInvalid: isInvalid,
                    isFirstDayInWeek: isFirstDayInWeek,
                    isLastDayInWeek: isLastDayInWeek,
                    isSelectionStart: isSelectionStart,
                    isSelectionEnd: isSelectionEnd,
                    isPreviousDayNotSelected: isPreviousDayNotSelected,
                    isNextDayNotSelected: isNextDayNotSelected
                }),
                role: "presentation"
            })
        ]
    });
};
/**
 * Calculate the week index (0-based) and day index (0-based) for a given date within a month in a calendar.
 * @param date - The date to calculate indices for.
 * @param locale - The locale string (e.g., 'en-US', 'fr-FR', 'hi-IN-u-ca-indian').
 * @param firstDayOfWeek - Optional override for the first day of the week ('sun', 'mon', 'tue', etc.).
 * @returns Object with weekIndex and dayIndex.
 */ function $f06f4d5597ad704c$var$useWeekAndDayIndices(date, locale, firstDayOfWeek) {
    let result = (0, $gwkOZ$useMemo)(()=>{
        // Get the day index within the week (0-6)
        const dayIndex = (0, $gwkOZ$getDayOfWeek)(date, locale, firstDayOfWeek);
        const monthStart = (0, $gwkOZ$startOfMonth)(date);
        // Calculate the week index by finding which week this date falls into
        // within the month's calendar grid
        const monthStartDayOfWeek = (0, $gwkOZ$getDayOfWeek)(monthStart, locale, firstDayOfWeek);
        const dayOfMonth = date.day;
        const weekIndex = Math.floor((dayOfMonth + monthStartDayOfWeek - 1) / 7);
        const lastDayOfMonth = (0, $gwkOZ$startOfMonth)(date).add({
            months: 1
        }).subtract({
            days: 1
        });
        const lastWeekIndex = Math.floor((lastDayOfMonth.day + monthStartDayOfWeek - 1) / 7);
        return {
            weekIndex: weekIndex,
            lastWeekIndex: lastWeekIndex,
            dayIndex: dayIndex
        };
    }, [
        date,
        locale,
        firstDayOfWeek
    ]);
    return result;
}


export {$f06f4d5597ad704c$export$3b805cea1f178355 as CalendarContext, $f06f4d5597ad704c$export$e1aef45b828286de as Calendar, $f06f4d5597ad704c$export$9c75275274db0b56 as CalendarHeader, $f06f4d5597ad704c$export$5bd780d491cfc46c as CalendarGrid, $f06f4d5597ad704c$export$adb29da0ac001538 as CalendarButton};
//# sourceMappingURL=Calendar.mjs.map
