import "./DatePicker.css";
import {Calendar as $f06f4d5597ad704c$export$e1aef45b828286de} from "./Calendar.mjs";
import $2d13361ea962c695$export$2e2bcd8739ae039 from "../../icons/Calendar.mjs";
import {DateInput as $0e78e2b1ea2e947e$export$7edc06cf1783b30f, DateInputContainer as $0e78e2b1ea2e947e$export$3f08d3c48fa697, InvalidIndicator as $0e78e2b1ea2e947e$export$19696856283ab185} from "./DateField.mjs";
import {FieldGroup as $9afd80978c252040$export$f0fe469072bc6950, FieldLabel as $9afd80978c252040$export$1acdcf5a973a8414, HelpText as $9afd80978c252040$export$a67c0bc59081311a} from "./Field.mjs";
import {IconContext as $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed} from "../../icons/Icon.mjs";
import $djrek$intlStringsmjs from "./intlStrings.mjs";
import {Popover as $88b746eba92c8d0d$export$5b6b19405a83ff9d} from "./Popover.mjs";
import {pressScale as $10ea7662e51a285b$export$56e8cba416805d8d} from "./pressScale.mjs";
import {TimeField as $a4c1b812c7e17006$export$5eaee2322dd727eb} from "./TimeField.mjs";
import {useSpectrumContextProps as $5ce63c423902f47d$export$764f6146fadd77f7} from "../../icons/useSpectrumContextProps.mjs";
import {jsx as $djrek$jsx, jsxs as $djrek$jsxs, Fragment as $djrek$Fragment} from "react/jsx-runtime";
import {DatePicker as $djrek$DatePicker} from "react-aria-components/DatePicker";
import {Button as $djrek$Button} from "react-aria-components/Button";
import {Provider as $djrek$Provider} from "react-aria-components/slots";
import {createContext as $djrek$createContext, forwardRef as $djrek$forwardRef, useContext as $djrek$useContext, useState as $djrek$useState, useRef as $djrek$useRef} from "react";
import {Dialog as $djrek$Dialog, OverlayTriggerStateContext as $djrek$OverlayTriggerStateContext} from "react-aria-components/Dialog";
import {FormContext as $djrek$FormContext} from "react-aria-components/Form";
import {useLocalizedStringFormatter as $djrek$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 $1196aa313ab37be1$export$cf316c7f3b44c11e = /*#__PURE__*/ (0, $djrek$createContext)(null);
const $1196aa313ab37be1$var$inputButton = function anonymous(props) {
    let rules = " ";
    if (props.isFocusVisible) rules += ' _Lf12';
    else rules += ' _Le12';
    rules += ' Oh12';
    rules += ' Olc12';
    rules += ' _Mc12';
    rules += ' _Kd12';
    if (props.size === "XL") rules += ' -SFnbic-_JaP8ec12';
    else if (props.size === "L") rules += ' -SFnbic-_J0K2hn12';
    else if (props.size === "S") rules += ' -SFnbic-_JJOW22b12';
    else if (props.size === "XS") rules += ' -SFnbic-_JICefdd12';
    else rules += ' -SFnbic-_Jb12';
    rules += ' -Bu7z1c-oa12';
    rules += ' oj12';
    rules += ' nj12';
    rules += ' kj12';
    rules += ' jj12';
    rules += ' _Pc12';
    if (props.size === "XL") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "L") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "M") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    } else if (props.size === "S") {
        rules += ' uk12';
        rules += ' ucJ9TBTb12';
        rules += ' ud3Euai12';
        rules += ' uea12';
        rules += ' ugb12';
        rules += ' uhd12';
        rules += ' uje12';
        rules += ' u2NhKxcl12';
        rules += ' uic12';
    }
    if (props.size === "XL") {
        rules += ' -_6BNtrc-e12';
        rules += ' vx12';
    } else if (props.size === "L") {
        rules += ' -_6BNtrc-d12';
        rules += ' vx12';
    } else if (props.size === "M") {
        rules += ' -_6BNtrc-c12';
        rules += ' vx12';
    } else if (props.size === "S") {
        rules += ' -_6BNtrc-b12';
        rules += ' vx12';
    }
    if (props.size === "XL") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "L") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "M") {
        rules += ' xb12';
        rules += ' _xa12';
    } else if (props.size === "S") {
        rules += ' xb12';
        rules += ' _xa12';
    }
    if (props.size === "XL") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "L") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "M") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    } else if (props.size === "S") {
        rules += ' _Fd12';
        rules += ' _FnuYUweb12';
    }
    if (props.isDisabled) rules += ' pp12';
    else {
        if (props.isPressed) rules += ' po12';
        else if (props.isFocusVisible) rules += ' po12';
        else if (props.isHovered) rules += ' po12';
        else rules += ' pt12';
    }
    rules += ' pla12';
    rules += ' ri12';
    rules += ' sd12';
    rules += ' _Wa12';
    rules += ' _je12';
    rules += ' eb12';
    rules += ' _Ca12';
    if (props.size === "XL") rules += ' ZC12';
    else if (props.size === "L") rules += ' Zo12';
    else if (props.size === "M") rules += ' Zm12';
    else if (props.size === "S") rules += ' Zu12';
    rules += ' Fd12';
    rules += ' Iw12';
    rules += ' fa12';
    rules += ' _va12';
    rules += ' Yd12';
    rules += ' Yle12';
    rules += ' Xb12';
    rules += ' Xlb12';
    rules += ' _2b12';
    rules += ' _2lb12';
    if (props.isDisabled) rules += ' gH12';
    else if (props.isOpen) rules += ' gF12';
    else {
        if (props.isPressed) rules += ' gF12';
        else if (props.isFocusVisible) rules += ' gF12';
        else if (props.isHovered) rules += ' gF12';
        else rules += ' gH12';
    }
    if (props.isDisabled) rules += ' gld12';
    else if (props.isOpen) rules += ' gle12';
    else if (props.isHovered) rules += ' gle12';
    else rules += ' glc12';
    return rules;
};
const $1196aa313ab37be1$export$5320dd0e349ed44d = " _vb12 _ua12 Na12 Ze4mUs12";
const $1196aa313ab37be1$export$5109c6dd95d8fb00 = /*#__PURE__*/ (0, $djrek$forwardRef)(function DatePicker(props1, ref) {
    [props1, ref] = (0, $5ce63c423902f47d$export$764f6146fadd77f7)(props1, ref, $1196aa313ab37be1$export$cf316c7f3b44c11e);
    let stringFormatter = (0, $djrek$useLocalizedStringFormatter)((0, ($parcel$interopDefault($djrek$intlStringsmjs))), '@react-spectrum/s2');
    let { label: label, contextualHelp: contextualHelp, description: descriptionMessage, errorMessage: errorMessage, isRequired: isRequired, size: size = 'M', labelPosition: labelPosition = 'top', necessityIndicator: necessityIndicator, labelAlign: labelAlign = 'start', UNSAFE_style: UNSAFE_style, UNSAFE_className: UNSAFE_className, styles: styles, placeholderValue: placeholderValue, maxVisibleMonths: maxVisibleMonths = 1, createCalendar: createCalendar, ...dateFieldProps } = props1;
    let formContext = (0, $djrek$useContext)((0, $djrek$FormContext));
    let [buttonHasFocus, setButtonHasFocus] = (0, $djrek$useState)(false);
    return /*#__PURE__*/ (0, $djrek$jsx)((0, $djrek$DatePicker), {
        ref: ref,
        isRequired: isRequired,
        ...dateFieldProps,
        style: UNSAFE_style,
        className: (UNSAFE_className || '') + function anonymous(props, overrides) {
            let rules = " ";
            let gridColumnStart = false;
            let gridColumnEnd = 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") gridColumnStart = true;
                if (p[1] === "y") gridColumnEnd = true;
                rules += p[0];
            }
            rules += ' se12';
            if (props.isInForm) {
                if (!gridColumnStart) rules += ' z2mU12';
            }
            if (props.isInForm) {
                if (props.labelPosition === "side") {
                    if (!gridColumnEnd) rules += ' yvoofG12';
                }
            }
            if (props.isInForm) rules += ' DLwlgod12';
            else {
                if (props.labelPosition === "side") rules += ' DPlN5qb12';
                else if (props.labelPosition === "top") rules += ' DM8Mfn12';
            }
            if (props.labelPosition === "side") rules += ' EPlN5qb12';
            else if (props.labelPosition === "top") rules += ' E4w1sLc12';
            if (props.labelPosition === "side") rules += ' CbRM95c12';
            else if (props.labelPosition === "top") rules += ' Cxaocre12';
            if (props.size === "XL") {
                rules += ' -_6BNtrc-e12';
                rules += ' vx12';
            } else if (props.size === "L") {
                rules += ' -_6BNtrc-d12';
                rules += ' vx12';
            } else if (props.size === "S") {
                rules += ' -_6BNtrc-b12';
                rules += ' vx12';
            } else if (props.size === "XS") {
                rules += ' -_6BNtrc-a12';
                rules += ' vx12';
            } else {
                rules += ' -_6BNtrc-c12';
                rules += ' vx12';
            }
            rules += ' ea12';
            rules += ' _Fd12';
            rules += ' _FnuYUweb12';
            if (props.size === "XL") rules += ' -BhX7R-Fz12';
            else if (props.size === "L") rules += ' -BhX7R-Fv12';
            else if (props.size === "S") rules += ' -BhX7R-Fp12';
            else if (props.size === "XS") rules += ' -BhX7R-Fn12';
            else rules += ' -BhX7R-Fx12';
            rules += ' -AJjOLd-UVkF0Db12';
            rules += ' qg12';
            rules += ' __ca12';
            return rules;
        }({
            isInForm: !!formContext,
            labelPosition: labelPosition,
            size: size
        }, styles),
        children: ({ isDisabled: isDisabled, isInvalid: isInvalid, isOpen: isOpen, state: state })=>{
            let placeholder = placeholderValue ?? undefined;
            let timePlaceholder = placeholder && 'hour' in placeholder ? placeholder : undefined;
            let timeMinValue = props1.minValue && 'hour' in props1.minValue ? props1.minValue : undefined;
            let timeMaxValue = props1.maxValue && 'hour' in props1.maxValue ? props1.maxValue : undefined;
            let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' ? state.granularity : undefined;
            let showTimeField = !!timeGranularity;
            return /*#__PURE__*/ (0, $djrek$jsxs)((0, $djrek$Fragment), {
                children: [
                    /*#__PURE__*/ (0, $djrek$jsx)((0, $9afd80978c252040$export$1acdcf5a973a8414), {
                        isDisabled: isDisabled,
                        isRequired: isRequired,
                        size: size,
                        labelPosition: labelPosition,
                        labelAlign: labelAlign,
                        necessityIndicator: necessityIndicator,
                        contextualHelp: contextualHelp,
                        children: label
                    }),
                    /*#__PURE__*/ (0, $djrek$jsxs)((0, $9afd80978c252040$export$f0fe469072bc6950), {
                        role: "presentation",
                        shouldTurnOffFocusRing: buttonHasFocus,
                        isDisabled: isDisabled,
                        isInvalid: isInvalid,
                        size: size,
                        styles: function anonymous(props) {
                            let rules = " ";
                            rules += ' zXcEWr12';
                            rules += ' yXcEWr12';
                            rules += ' BXcEWr12';
                            rules += ' AXcEWr12';
                            if (props.size === "XL") rules += ' Nl12';
                            else if (props.size === "L") rules += ' Nj12';
                            else if (props.size === "S") rules += ' Nf12';
                            else if (props.size === "XS") rules += ' Ne12';
                            else rules += ' Nk12';
                            if (props.isQuiet) rules += ' _qd12';
                            else rules += ' _qtb12';
                            if (props.size === "XL") rules += ' -Anxdcc-Zt12';
                            else if (props.size === "L") rules += ' -Anxdcc-ZStdtne12';
                            else if (props.size === "S") rules += ' -Anxdcc-Zr12';
                            else rules += ' -Anxdcc-Z3fn9H12';
                            rules += ' __v6TNLWb12';
                            rules += ' __Wb12';
                            rules += ' SMBFGYc12';
                            rules += ' RfBFGYc12';
                            rules += ' -S_-Sv12';
                            if (props.size === "XL") rules += ' -R_-RWJpoB12';
                            else if (props.size === "L") rules += ' -R_-RWJpoB12';
                            else if (props.size === "M") rules += ' -R_-Rp12';
                            else if (props.size === "S") rules += ' -R_-Rj12';
                            return rules;
                        }({
                            size: size
                        }),
                        children: [
                            /*#__PURE__*/ (0, $djrek$jsx)((0, $0e78e2b1ea2e947e$export$3f08d3c48fa697), {
                                children: /*#__PURE__*/ (0, $djrek$jsx)((0, $0e78e2b1ea2e947e$export$7edc06cf1783b30f), {})
                            }),
                            /*#__PURE__*/ (0, $djrek$jsx)((0, $0e78e2b1ea2e947e$export$19696856283ab185), {
                                isInvalid: isInvalid,
                                isDisabled: isDisabled
                            }),
                            /*#__PURE__*/ (0, $djrek$jsx)($1196aa313ab37be1$export$adb29da0ac001538, {
                                isOpen: isOpen,
                                size: size,
                                setButtonHasFocus: setButtonHasFocus
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $djrek$jsxs)($1196aa313ab37be1$export$f3ce207574a3cffe, {
                        shouldFlip: props1.shouldFlip,
                        children: [
                            /*#__PURE__*/ (0, $djrek$jsx)((0, $f06f4d5597ad704c$export$e1aef45b828286de), {
                                visibleMonths: maxVisibleMonths,
                                createCalendar: createCalendar,
                                errorMessage: errorMessage
                            }),
                            showTimeField && /*#__PURE__*/ (0, $djrek$jsx)("div", {
                                className: " sd12 Ul12 ql12 _qb12",
                                children: /*#__PURE__*/ (0, $djrek$jsx)((0, $a4c1b812c7e17006$export$5eaee2322dd727eb), {
                                    styles: $1196aa313ab37be1$export$5320dd0e349ed44d,
                                    label: stringFormatter.format('datepicker.time'),
                                    value: state.timeValue,
                                    // TODO: why do i need the cast?
                                    onChange: (v)=>state.setTimeValue(v),
                                    placeholderValue: timePlaceholder,
                                    granularity: timeGranularity,
                                    minValue: timeMinValue,
                                    maxValue: timeMaxValue,
                                    hourCycle: props1.hourCycle,
                                    hideTimeZone: props1.hideTimeZone
                                })
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $djrek$jsx)((0, $9afd80978c252040$export$a67c0bc59081311a), {
                        size: size,
                        isDisabled: isDisabled,
                        isInvalid: isInvalid,
                        description: descriptionMessage,
                        children: errorMessage
                    })
                ]
            });
        }
    });
});
function $1196aa313ab37be1$export$f3ce207574a3cffe(props) {
    return /*#__PURE__*/ (0, $djrek$jsx)((0, $88b746eba92c8d0d$export$5b6b19405a83ff9d), {
        ...props,
        hideArrow: true,
        padding: "none",
        children: /*#__PURE__*/ (0, $djrek$jsx)("div", {
            className: " Sf12 Rf12 Th12 Qh12 _Na12 Pa12 sd12 _ta12 Ul12 ql12 _oa12 Za12 Fb12",
            children: /*#__PURE__*/ (0, $djrek$jsx)((0, $djrek$Dialog), {
                children: /*#__PURE__*/ (0, $djrek$jsx)((0, $djrek$Provider), {
                    values: [
                        [
                            (0, $djrek$OverlayTriggerStateContext),
                            null
                        ]
                    ],
                    children: props.children
                })
            })
        })
    });
}
function $1196aa313ab37be1$export$adb29da0ac001538(props) {
    let buttonRef = (0, $djrek$useRef)(null);
    let { isOpen: isOpen, size: size, setButtonHasFocus: setButtonHasFocus } = props;
    return /*#__PURE__*/ (0, $djrek$jsx)((0, $djrek$Button), {
        ref: buttonRef,
        // Prevent press scale from sticking while DatePicker is open.
        // @ts-ignore
        isPressed: false,
        onFocusChange: setButtonHasFocus,
        style: (0, $10ea7662e51a285b$export$56e8cba416805d8d)(buttonRef),
        className: (renderProps)=>$1196aa313ab37be1$var$inputButton({
                ...renderProps,
                size: size,
                isOpen: isOpen
            }),
        children: /*#__PURE__*/ (0, $djrek$jsx)((0, $djrek$Provider), {
            values: [
                [
                    (0, $ac8c32e6775ddd1f$export$a49f528ae1a4d0ed),
                    {
                        styles: " -_8sjo0b-t5ZbAob12 Za8Mfn12 Fa8Mfn12"
                    }
                ]
            ],
            children: /*#__PURE__*/ (0, $djrek$jsx)((0, $2d13361ea962c695$export$2e2bcd8739ae039), {})
        })
    });
}


export {$1196aa313ab37be1$export$cf316c7f3b44c11e as DatePickerContext, $1196aa313ab37be1$export$5320dd0e349ed44d as timeField, $1196aa313ab37be1$export$5109c6dd95d8fb00 as DatePicker, $1196aa313ab37be1$export$adb29da0ac001538 as CalendarButton, $1196aa313ab37be1$export$f3ce207574a3cffe as CalendarPopover};
//# sourceMappingURL=DatePicker.mjs.map
