import "./Calendar.css";
import {ActionButton as $da878a05ab4a403e$export$cfc7921d29ef7b80} from "./ActionButton.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 {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import $5c3fed25abf344cc$export$2e2bcd8739ae039 from "../icons/ChevronLeft.mjs";
import $04f4b15c8c66bb2a$export$2e2bcd8739ae039 from "../icons/ChevronRight.mjs";
import {helpTextStyles as $9afd80978c252040$export$13b1fd5431595bf6} from "./Field.mjs";
import $gwkOZ$intlStringsmjs from "./intlStrings.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, Provider as $gwkOZ$Provider, Text as $gwkOZ$Text, useSlottedContext as $gwkOZ$useSlottedContext, RangeCalendarContext as $gwkOZ$RangeCalendarContext, CalendarContext as $gwkOZ$CalendarContext, CalendarGrid as $gwkOZ$CalendarGrid, CalendarGridHeader as $gwkOZ$CalendarGridHeader, CalendarGridBody as $gwkOZ$CalendarGridBody, CalendarStateContext as $gwkOZ$CalendarStateContext, RangeCalendarStateContext as $gwkOZ$RangeCalendarStateContext, CalendarHeaderCell as $gwkOZ$CalendarHeaderCell, CalendarCell as $gwkOZ$CalendarCell} from "react-aria-components";
import {startOfMonth as $gwkOZ$startOfMonth, getDayOfWeek as $gwkOZ$getDayOfWeek} from "@internationalized/date";
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 {useLocalizedStringFormatter as $gwkOZ$useLocalizedStringFormatter, useDateFormatter as $gwkOZ$useDateFormatter, useLocale as $gwkOZ$useLocale} from "@react-aria/i18n";


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 matches = (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;
        rules += p[0];
    }
    rules += ' sd1';
    rules += ' _ta1';
    rules += ' Uj1';
    rules += ' qj1';
    if (!width) rules += ' ZJ1';
    rules += ' __ca1';
    return rules;
};
const $f06f4d5597ad704c$var$headerStyles = " sd1 eb1 _Ce1 Za1";
const $f06f4d5597ad704c$var$headingStyles = " sd1 eb1 _Ce1 Jy1 Gy1 Iy1 Hy1 Za1";
const $f06f4d5597ad704c$var$titleStyles = " uk1 ucJ9TBTb1 ud3Euai1 uea1 ugb1 uhd1 uje1 u2NhKxcl1 uic1 -_6BNtrc-e1 vx1 xd1 _xa1 xX0cczbc1 _xX0cczba1 xfd1 _xfa1 xfX0cczbc1 _xfX0cczba1 _Fd1 _FnuYUweb1 po1 _Wa1 _ub1 _va1 _sa1 Na1";
const $f06f4d5597ad704c$var$headerCellStyles = " uk1 ucJ9TBTb1 ud3Euai1 uea1 ugb1 uhd1 uje1 u2NhKxcl1 uic1 -_6BNtrc-c1 vx1 xd1 _xa1 xX0cczbc1 _xX0cczba1 xfd1 _xfa1 xfX0cczbc1 _xfX0cczba1 _Fd1 _FnuYUweb1 po1 ri1 _Wa1 Sp1 Sbd1 Rp1 Rkd1 Qe1";
const $f06f4d5597ad704c$var$cellStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Le1';
    rules += ' -uq4sQ-Sp1';
    if (props.isFirstChild) rules += ' Sd1';
    else rules += ' Sp1';
    if (props.isLastChild) rules += ' Rd1';
    else rules += ' Rp1';
    if (props.isFirstWeek) rules += ' Td1';
    else rules += ' Tj1';
    rules += ' Qj1';
    rules += ' _Pc1';
    rules += ' ZC1';
    rules += ' Fx1';
    if (props.isOutsideMonth) rules += ' sk1';
    else rules += ' sd1';
    rules += ' eb1';
    rules += ' _Ca1';
    rules += ' __ca1';
    return rules;
};
const $f06f4d5597ad704c$var$cellInnerStyles = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf1';
    else rules += ' _Le1';
    rules += ' Oh1';
    rules += ' Olc1';
    rules += ' _Mc1';
    if (props.isSelectionEnd) rules += ' _Kd1';
    else if (props.isSelectionStart) rules += ' _Kd1';
    else if (props.isSelected) {
        if (props.selectionMode === "range") rules += ' _Kb1';
        else if (props.selectionMode === "single") rules += ' _Kd1';
    } else if (props.isToday) rules += ' _Kd1';
    else rules += ' _Kb1';
    rules += ' Yd1';
    rules += ' Yle1';
    rules += ' Xb1';
    rules += ' Xlb1';
    rules += ' _2b1';
    rules += ' _2lb1';
    rules += ' _Pc1';
    rules += ' uk1';
    rules += ' ucJ9TBTb1';
    rules += ' ud3Euai1';
    rules += ' uea1';
    rules += ' ugb1';
    rules += ' uhd1';
    rules += ' uje1';
    rules += ' u2NhKxcl1';
    rules += ' uic1';
    rules += ' -_6BNtrc-c1';
    rules += ' vx1';
    rules += ' xb1';
    rules += ' _xa1';
    rules += ' _Fb1';
    rules += ' _FnuYUwec1';
    if (props.isDisabled) rules += ' pp1';
    else if (props.isSelectionEnd) rules += ' px1';
    else if (props.isSelectionStart) rules += ' px1';
    else if (props.isSelected) {
        if (props.selectionMode === "range") rules += ' pt1';
        else rules += ' px1';
    } else rules += ' pt1';
    if (props.isDisabled) rules += ' plc1';
    else if (props.isSelectionEnd) rules += ' ple1';
    else if (props.isSelectionStart) rules += ' ple1';
    else if (props.isSelected) rules += ' ple1';
    else if (props.isToday) rules += ' pla1';
    else rules += ' plb1';
    rules += ' ri1';
    rules += ' Za1';
    rules += ' Fx1';
    rules += ' og1';
    rules += ' ng1';
    rules += ' kg1';
    rules += ' jg1';
    rules += ' sd1';
    rules += ' eb1';
    rules += ' _Ca1';
    rules += ' _yb1';
    if (props.isSelectionEnd) {
        if (props.isInvalid) {
            if (props.isFocusVisible) {
                if (props.isUnavailable) rules += ' g7aei81';
                else rules += ' gYvV9s1';
            } else if (props.isPressed) rules += ' gYvV9s1';
            else if (props.isHovered) {
                if (props.isUnavailable) rules += ' g7aei81';
                else rules += ' gYvV9s1';
            } else rules += ' g7aei81';
        } else if (props.isDisabled) rules += ' g91';
        else if (props.isFocusVisible) rules += ' gUgARdd1';
        else if (props.isPressed) rules += ' gUgARdd1';
        else if (props.isHovered) rules += ' gUgARdd1';
        else rules += ' g5qAiPc1';
    } else if (props.isSelectionStart) {
        if (props.isInvalid) {
            if (props.isFocusVisible) {
                if (props.isUnavailable) rules += ' g7aei81';
                else rules += ' gYvV9s1';
            } else if (props.isPressed) rules += ' gYvV9s1';
            else if (props.isHovered) {
                if (props.isUnavailable) rules += ' g7aei81';
                else rules += ' gYvV9s1';
            } else rules += ' g7aei81';
        } else if (props.isDisabled) rules += ' g91';
        else if (props.isFocusVisible) rules += ' gUgARdd1';
        else if (props.isPressed) rules += ' gUgARdd1';
        else if (props.isHovered) rules += ' gUgARdd1';
        else rules += ' g5qAiPc1';
    } else if (props.isSelected) {
        if (props.selectionMode === "range") {
            if (props.isHovered) {
                if (props.isInvalid) {
                    if (props.isUnavailable) rules += ' g91';
                    else rules += ' gJj9Tpd1';
                } else rules += ' gNAacne1';
            }
        } else if (props.selectionMode === "single") {
            if (props.isInvalid) {
                if (props.isFocusVisible) rules += ' gYvV9s1';
                else if (props.isPressed) rules += ' gYvV9s1';
                else if (props.isHovered) rules += ' gYvV9s1';
                else rules += ' g7aei81';
            } else if (props.isDisabled) rules += ' g91';
            else if (props.isFocusVisible) rules += ' gUgARdd1';
            else if (props.isPressed) rules += ' gUgARdd1';
            else if (props.isHovered) rules += ' gUgARdd1';
            else rules += ' g5qAiPc1';
        }
    } else if (props.isToday) {
        if (props.isDisabled) rules += ' gH1';
        else {
            if (props.isPressed) rules += ' gw1';
            else if (props.isFocusVisible) rules += ' gw1';
            else if (props.isHovered) rules += ' gw1';
            else rules += ' gE1';
        }
    } else if (props.isDisabled) rules += ' g91';
    else if (props.isPressed) rules += ' gH1';
    else if (props.isHovered) {
        if (props.isUnavailable) rules += ' g91';
        else rules += ' gH1';
    } else rules += ' g91';
    if (props.isUnavailable) rules += ' gl91';
    else if (props.isSelectionEnd) rules += ' gle1';
    else if (props.isSelectionStart) rules += ' gle1';
    else if (props.isSelected) {
        if (props.selectionMode === "range") {
            if (props.isHovered) rules += ' gle1';
        } else if (props.selectionMode === "single") rules += ' gle1';
    } else if (props.isHovered) rules += ' gle1';
    else if (props.isToday) rules += ' glb1';
    else rules += ' gl91';
    return rules;
};
const $f06f4d5597ad704c$var$unavailableStyles = " _Pa1 WzErnCb1 _EjhYzGc1 _RjhYzGc1 FlAZvq1 _ZN7ydnb1 og1 ng1 kg1 jg1 g5ZbAob1";
const $f06f4d5597ad704c$var$selectionSpanStyles = function anonymous(props) {
    let rules = " ";
    rules += ' _Pa1';
    rules += ' _9a1';
    rules += ' Wr1';
    rules += ' _AOJNuv1';
    rules += ' _zr1';
    rules += ' _lr1';
    rules += ' _kc1';
    rules += ' hc1';
    rules += ' mc1';
    rules += ' lc1';
    rules += ' _ja1';
    if (props.isInvalid) rules += ' ip1';
    else rules += ' ix1';
    rules += ' ilb1';
    rules += ' og1';
    rules += ' kg1';
    rules += ' ng1';
    rules += ' jg1';
    if (props.isInvalid) rules += ' gZbQnx1';
    else rules += ' gG1';
    rules += ' gle1';
    rules += ' _yb1';
    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');
    return /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $gwkOZ$Calendar), {
        ...otherProps,
        ref: ref,
        visibleDuration: {
            months: visibleMonths
        },
        style: UNSAFE_style,
        className: (UNSAFE_className || '') + $f06f4d5597ad704c$var$calendarStyles(null, 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$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$export$77af08ed164baa7, {}),
                                /*#__PURE__*/ (0, $gwkOZ$jsx)($f06f4d5597ad704c$export$adb29da0ac001538, {
                                    slot: "next",
                                    children: /*#__PURE__*/ (0, $gwkOZ$jsx)((0, $04f4b15c8c66bb2a$export$2e2bcd8739ae039), {})
                                })
                            ]
                        })
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: " sd1 _tc1 Uj1 qj1 Za1 ed1",
                        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$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: " __na1 __oe1 _Bb1",
        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
                    })
            })
        ]
    });
};
const $f06f4d5597ad704c$export$77af08ed164baa7 = ()=>{
    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: " _6b1 ZC1"
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: " _6b1 Zo1"
                    }),
                    /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: " _6b1 ZC1"
                    }),
                    /*#__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-a1';
                rules += ' __Ha1';
            }
            if (props.direction === "rtl") {
                rules += ' -_04Pn4c-a1';
                rules += ' __Ha1';
            }
            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 } = $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 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
            }),
        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 { weekIndex: weekIndex, dayIndex: dayIndex, date: date, renderProps: renderProps, state: state, isRangeSelection: isRangeSelection } = props;
    let { getDatesInWeek: getDatesInWeek } = state;
    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 startDate = (0, $gwkOZ$startOfMonth)(date);
    let datesInWeek = getDatesInWeek(weekIndex, startDate);
    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);
    };
    // Starting from the current day, find the first day before it in the current week that is not selected.
    // Then, the span of selected days is the current day minus the first unselected day.
    let firstUnselectedInRangeInWeek = datesInWeek.slice(0, dayIndex + 1).reverse().findIndex((date, i)=>{
        return date && i > 0 && (!isDateInRange(date) || date.month !== props.date.month);
    });
    let selectionSpan = -1;
    if (firstUnselectedInRangeInWeek > -1 && isSelected) selectionSpan = firstUnselectedInRangeInWeek - 1;
    else if (isSelected) selectionSpan = dayIndex;
    let prevDay = date.subtract({
        days: 1
    });
    let nextDay = date.add({
        days: 1
    });
    // 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: " _Pc1 ZvFFGYc1 -_4Isswc-ZvFFGYc1 -Z_-ZC1",
        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", {
                        children: formattedDate
                    }),
                    isUnavailable && /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                        className: $f06f4d5597ad704c$var$unavailableStyles,
                        role: "presentation"
                    })
                ]
            }),
            isBackgroundStyleApplied && /*#__PURE__*/ (0, $gwkOZ$jsx)("div", {
                style: {
                    '--selection-span': selectionSpan
                },
                className: $f06f4d5597ad704c$var$selectionSpanStyles({
                    isInvalid: isInvalid
                }),
                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 { dayIndex: dayIndex, weekIndex: weekIndex } = (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);
        return {
            weekIndex: weekIndex,
            dayIndex: dayIndex
        };
    }, [
        date,
        locale,
        firstDayOfWeek
    ]);
    return {
        dayIndex: dayIndex,
        weekIndex: weekIndex
    };
}


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