import {dom as $7230ffa83bc0c2cf$export$df3a06d6289f983e, removeDataAttributes as $7230ffa83bc0c2cf$export$ef03459518577ad4, useContextProps as $7230ffa83bc0c2cf$export$29f1550f4b0d4415, useRenderProps as $7230ffa83bc0c2cf$export$4d86445c2cf5e3} from "./utils.mjs";
import {useSwitch as $kf3DM$useSwitch} from "react-aria/useSwitch";
import {filterDOMProps as $kf3DM$filterDOMProps} from "react-aria/private/utils/filterDOMProps";
import {mergeProps as $kf3DM$mergeProps} from "react-aria/mergeProps";
import {mergeRefs as $kf3DM$mergeRefs} from "react-aria/private/utils/mergeRefs";
import $kf3DM$react, {createContext as $kf3DM$createContext, forwardRef as $kf3DM$forwardRef} from "react";
import {useToggleState as $kf3DM$useToggleState} from "react-stately/useToggleState";
import {useFocusRing as $kf3DM$useFocusRing} from "react-aria/useFocusRing";
import {useHover as $kf3DM$useHover} from "react-aria/useHover";
import {useObjectRef as $kf3DM$useObjectRef} from "react-aria/useObjectRef";
import {VisuallyHidden as $kf3DM$VisuallyHidden} from "react-aria/VisuallyHidden";

/*
 * 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 $24585aa46d6ffdff$export$8699e3b644d5a28a = /*#__PURE__*/ (0, $kf3DM$createContext)(null);
const $24585aa46d6ffdff$export$b5d5cf8927ab7262 = /*#__PURE__*/ (0, $kf3DM$forwardRef)(function Switch(props, ref) {
    let { inputRef: userProvidedInputRef = null, ...otherProps } = props;
    [props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(otherProps, ref, $24585aa46d6ffdff$export$8699e3b644d5a28a);
    let inputRef = (0, $kf3DM$useObjectRef)((0, $kf3DM$mergeRefs)(userProvidedInputRef, props.inputRef !== undefined ? props.inputRef : null));
    let state = (0, $kf3DM$useToggleState)(props);
    let { labelProps: labelProps, inputProps: inputProps, isSelected: isSelected, isDisabled: isDisabled, isReadOnly: isReadOnly, isPressed: isPressed } = (0, $kf3DM$useSwitch)({
        ...(0, $7230ffa83bc0c2cf$export$ef03459518577ad4)(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, $kf3DM$useFocusRing)();
    let isInteractionDisabled = props.isDisabled || props.isReadOnly;
    let { hoverProps: hoverProps, isHovered: isHovered } = (0, $kf3DM$useHover)({
        ...props,
        isDisabled: isInteractionDisabled
    });
    let renderProps = (0, $7230ffa83bc0c2cf$export$4d86445c2cf5e3)({
        ...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, $kf3DM$filterDOMProps)(props, {
        global: true
    });
    delete DOMProps.id;
    delete DOMProps.onClick;
    return /*#__PURE__*/ (0, $kf3DM$react).createElement((0, $7230ffa83bc0c2cf$export$df3a06d6289f983e).label, {
        ...(0, $kf3DM$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, $kf3DM$react).createElement((0, $kf3DM$VisuallyHidden), {
        elementType: "span"
    }, /*#__PURE__*/ (0, $kf3DM$react).createElement("input", {
        ...(0, $kf3DM$mergeProps)(inputProps, focusProps),
        ref: inputRef
    })), renderProps.children);
});


export {$24585aa46d6ffdff$export$8699e3b644d5a28a as SwitchContext, $24585aa46d6ffdff$export$b5d5cf8927ab7262 as Switch};
//# sourceMappingURL=Switch.mjs.map
