require("./DateRangePicker.css");
var $e6aad0776f57e0e9$exports = require("./DatePicker.cjs");
var $d19642654b699f84$exports = require("./DateField.cjs");
var $a0b996a550bb0891$exports = require("./Field.cjs");
var $4526404114e78c80$exports = require("./intlStrings.cjs");
var $ad2936801c627ac5$exports = require("./RangeCalendar.cjs");
var $7b93ad26130ad3f8$exports = require("./TimeField.cjs");
var $ac757a4c2bd72aee$exports = require("../icons/useSpectrumContextProps.cjs");
var $bwmQw$reactjsxruntime = require("react/jsx-runtime");
var $bwmQw$reactariacomponents = require("react-aria-components");
var $bwmQw$react = require("react");
var $bwmQw$reactariai18n = require("@react-aria/i18n");


function $parcel$interopDefault(a) {
  return a && a.__esModule ? a.default : a;
}

function $parcel$export(e, n, v, s) {
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}

$parcel$export(module.exports, "DateRangePickerContext", () => $932c2841127a87c7$export$8282edba42ee28a);
$parcel$export(module.exports, "DateRangePicker", () => $932c2841127a87c7$export$17334619f3ac2224);
/*
 * 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 $932c2841127a87c7$export$8282edba42ee28a = /*#__PURE__*/ (0, $bwmQw$react.createContext)(null);
const $932c2841127a87c7$export$17334619f3ac2224 = /*#__PURE__*/ (0, $bwmQw$react.forwardRef)(function DateRangePicker(props, ref) {
    [props, ref] = (0, $ac757a4c2bd72aee$exports.useSpectrumContextProps)(props, ref, $932c2841127a87c7$export$8282edba42ee28a);
    let stringFormatter = (0, $bwmQw$reactariai18n.useLocalizedStringFormatter)((0, ($parcel$interopDefault($4526404114e78c80$exports))), '@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 } = props;
    let formContext = (0, $bwmQw$react.useContext)((0, $bwmQw$reactariacomponents.FormContext));
    let [buttonHasFocus, setButtonHasFocus] = (0, $bwmQw$react.useState)(false);
    return /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $bwmQw$reactariacomponents.DateRangePicker), {
        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 = props.minValue && 'hour' in props.minValue ? props.minValue : undefined;
            let timeMaxValue = props.maxValue && 'hour' in props.maxValue ? props.maxValue : undefined;
            let timeGranularity = state.granularity === 'hour' || state.granularity === 'minute' || state.granularity === 'second' ? state.granularity : undefined;
            let showTimeField = !!timeGranularity;
            return /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsxs)((0, $bwmQw$reactjsxruntime.Fragment), {
                children: [
                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.FieldLabel), {
                        isDisabled: isDisabled,
                        isRequired: isRequired,
                        size: size,
                        labelPosition: labelPosition,
                        labelAlign: labelAlign,
                        necessityIndicator: necessityIndicator,
                        contextualHelp: contextualHelp,
                        children: label
                    }),
                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsxs)((0, $a0b996a550bb0891$exports.FieldGroup), {
                        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';
                            rules += ' -R_-Rp12';
                            return rules;
                        }({
                            size: size
                        }),
                        children: [
                            /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsxs)((0, $d19642654b699f84$exports.DateInputContainer), {
                                children: [
                                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $d19642654b699f84$exports.DateInput), {
                                        slot: "start"
                                    }),
                                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)("span", {
                                        "aria-hidden": "true",
                                        className: " _va12 _ua12 Sj12 Rj12",
                                        children: "\u2013"
                                    }),
                                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $d19642654b699f84$exports.DateInput), {
                                        slot: "end"
                                    })
                                ]
                            }),
                            /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $d19642654b699f84$exports.InvalidIndicator), {
                                isInvalid: isInvalid,
                                isDisabled: isDisabled
                            }),
                            /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)("div", {
                                className: " _va12 _ub12 sd12 _Cb12",
                                children: /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $e6aad0776f57e0e9$exports.CalendarButton), {
                                    isOpen: isOpen,
                                    size: size,
                                    setButtonHasFocus: setButtonHasFocus
                                })
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsxs)((0, $e6aad0776f57e0e9$exports.CalendarPopover), {
                        shouldFlip: props.shouldFlip,
                        children: [
                            /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $ad2936801c627ac5$exports.RangeCalendar), {
                                visibleMonths: maxVisibleMonths,
                                createCalendar: createCalendar
                            }),
                            showTimeField && /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsxs)("div", {
                                className: " sd12 Ul12 ql12 _qb12 JA12",
                                children: [
                                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $7b93ad26130ad3f8$exports.TimeField), {
                                        styles: (0, $e6aad0776f57e0e9$exports.timeField),
                                        label: stringFormatter.format('datepicker.startTime'),
                                        value: state.timeRange?.start || null,
                                        onChange: (v)=>state.setTime('start', v),
                                        placeholderValue: timePlaceholder,
                                        granularity: timeGranularity,
                                        minValue: timeMinValue,
                                        maxValue: timeMaxValue,
                                        hourCycle: props.hourCycle,
                                        hideTimeZone: props.hideTimeZone
                                    }),
                                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $7b93ad26130ad3f8$exports.TimeField), {
                                        styles: (0, $e6aad0776f57e0e9$exports.timeField),
                                        label: stringFormatter.format('datepicker.endTime'),
                                        value: state.timeRange?.end || null,
                                        onChange: (v)=>state.setTime('end', v),
                                        placeholderValue: timePlaceholder,
                                        granularity: timeGranularity,
                                        minValue: timeMinValue,
                                        maxValue: timeMaxValue,
                                        hourCycle: props.hourCycle,
                                        hideTimeZone: props.hideTimeZone
                                    })
                                ]
                            })
                        ]
                    }),
                    /*#__PURE__*/ (0, $bwmQw$reactjsxruntime.jsx)((0, $a0b996a550bb0891$exports.HelpText), {
                        size: size,
                        isDisabled: isDisabled,
                        isInvalid: isInvalid,
                        description: descriptionMessage,
                        children: errorMessage
                    })
                ]
            });
        }
    });
});


//# sourceMappingURL=DateRangePicker.cjs.map
