var $048d76b84370f141$exports = require("./utils.cjs");
var $goUg1$reactariauseSwitch = require("react-aria/useSwitch");
var $goUg1$reactariaprivateutilsfilterDOMProps = require("react-aria/private/utils/filterDOMProps");
var $goUg1$reactariamergeProps = require("react-aria/mergeProps");
var $goUg1$reactariaprivateutilsmergeRefs = require("react-aria/private/utils/mergeRefs");
var $goUg1$react = require("react");
var $goUg1$reactstatelyuseToggleState = require("react-stately/useToggleState");
var $goUg1$reactariauseFocusRing = require("react-aria/useFocusRing");
var $goUg1$reactariauseHover = require("react-aria/useHover");
var $goUg1$reactariauseObjectRef = require("react-aria/useObjectRef");
var $goUg1$reactariaVisuallyHidden = require("react-aria/VisuallyHidden");


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, "SwitchContext", function () { return $f78e777132fa7bc2$export$8699e3b644d5a28a; });
$parcel$export(module.exports, "Switch", function () { return $f78e777132fa7bc2$export$b5d5cf8927ab7262; });
/*
 * Copyright 2022 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 $f78e777132fa7bc2$export$8699e3b644d5a28a = /*#__PURE__*/ (0, $goUg1$react.createContext)(null);
const $f78e777132fa7bc2$export$b5d5cf8927ab7262 = /*#__PURE__*/ (0, $goUg1$react.forwardRef)(function Switch(props, ref) {
    let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
    [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(otherProps, ref, $f78e777132fa7bc2$export$8699e3b644d5a28a);
    let inputRef = (0, $goUg1$reactariauseObjectRef.useObjectRef)((0, $goUg1$reactariaprivateutilsmergeRefs.mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
    let state = (0, $goUg1$reactstatelyuseToggleState.useToggleState)(props);
    let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isDisabled: isDisabled, isReadOnly: isReadOnly, isPressed: isPressed } = (0, $goUg1$reactariauseSwitch.useSwitch)({
        ...(0, $048d76b84370f141$exports.removeDataAttributes)(props),
        // ReactNode type doesn't allow function children.
        children: typeof props.children === 'function' ? true : props.children
    }, state, inputRef);
    let { isFocused: isFocused, isFocusVisible: isFocusVisible, focusProps: focusProps } = (0, $goUg1$reactariauseFocusRing.useFocusRing)();
    let isInteractionDisabled = props.isDisabled || props.isReadOnly;
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $goUg1$reactariauseHover.useHover)({
        ...props,
        isDisabled: isInteractionDisabled
    });
    let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
        ...props,
        defaultClassName: 'react-aria-Switch',
        values: {
            isSelected: isSelected,
            isPressed: isPressed,
            isHovered: isHovered,
            isFocused: isFocused,
            isFocusVisible: isFocusVisible,
            isDisabled: isDisabled,
            isReadOnly: isReadOnly,
            state: state
        }
    });
    let DOMProps = (0, $goUg1$reactariaprivateutilsfilterDOMProps.filterDOMProps)(props, {
        global: true
    });
    delete DOMProps.id;
    delete DOMProps.onClick;
    return /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement((0, $048d76b84370f141$exports.dom).label, {
        ...(0, $goUg1$reactariamergeProps.mergeProps)(DOMProps, labelProps, hoverProps, renderProps),
        ref: ref,
        slot: props.slot || undefined,
        "data-selected": isSelected || undefined,
        "data-pressed": isPressed || undefined,
        "data-hovered": isHovered || undefined,
        "data-focused": isFocused || undefined,
        "data-focus-visible": isFocusVisible || undefined,
        "data-disabled": isDisabled || undefined,
        "data-readonly": isReadOnly || undefined
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement((0, $goUg1$reactariaVisuallyHidden.VisuallyHidden), {
        elementType: "span"
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($goUg1$react))).createElement("input", {
        ...(0, $goUg1$reactariamergeProps.mergeProps)(inputProps, focusProps),
        ref: inputRef
    })), renderProps.children);
});


//# sourceMappingURL=Switch.cjs.map
