import {dom as $7230ffa83bc0c2cf$export$df3a06d6289f983e, Provider as $7230ffa83bc0c2cf$export$2881499e37b75b9a, useContextProps as $7230ffa83bc0c2cf$export$29f1550f4b0d4415, useRenderProps as $7230ffa83bc0c2cf$export$4d86445c2cf5e3} from "./utils.mjs";
import {OverlayArrowContext as $4fcfe18fac72dabd$export$2de4954e8ae13b9f} from "./OverlayArrow.mjs";
import {useOverlayPosition as $4nVq8$useOverlayPosition} from "react-aria/private/overlays/useOverlayPosition";
import {filterDOMProps as $4nVq8$filterDOMProps} from "react-aria/private/utils/filterDOMProps";
import {FocusableProvider as $4nVq8$FocusableProvider} from "react-aria/private/interactions/useFocusable";
import {mergeProps as $4nVq8$mergeProps} from "react-aria/mergeProps";
import {OverlayContainer as $4nVq8$OverlayContainer} from "react-aria/private/overlays/useModal";
import $4nVq8$react, {createContext as $4nVq8$createContext, useRef as $4nVq8$useRef, forwardRef as $4nVq8$forwardRef, useContext as $4nVq8$useContext} from "react";
import {useTooltipTriggerState as $4nVq8$useTooltipTriggerState} from "react-stately/useTooltipTriggerState";
import {useExitAnimation as $4nVq8$useExitAnimation, useEnterAnimation as $4nVq8$useEnterAnimation} from "react-aria/private/utils/animation";
import {useTooltipTrigger as $4nVq8$useTooltipTrigger, useTooltip as $4nVq8$useTooltip} from "react-aria/useTooltipTrigger";

/*
 * 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 $05a50f7d78b03ad9$export$7a7623236eec67fa = /*#__PURE__*/ (0, $4nVq8$createContext)(null);
const $05a50f7d78b03ad9$export$39ae08fa83328b12 = /*#__PURE__*/ (0, $4nVq8$createContext)(null);
function $05a50f7d78b03ad9$export$8c610744efcf8a1d(props) {
    let state = (0, $4nVq8$useTooltipTriggerState)(props);
    let ref = (0, $4nVq8$useRef)(null);
    let { triggerProps: triggerProps, tooltipProps: tooltipProps } = (0, $4nVq8$useTooltipTrigger)(props, state, ref);
    return /*#__PURE__*/ (0, $4nVq8$react).createElement((0, $7230ffa83bc0c2cf$export$2881499e37b75b9a), {
        values: [
            [
                $05a50f7d78b03ad9$export$7a7623236eec67fa,
                state
            ],
            [
                $05a50f7d78b03ad9$export$39ae08fa83328b12,
                {
                    ...tooltipProps,
                    triggerRef: ref
                }
            ]
        ]
    }, /*#__PURE__*/ (0, $4nVq8$react).createElement((0, $4nVq8$FocusableProvider), {
        ...triggerProps,
        ref: ref
    }, props.children));
}
const $05a50f7d78b03ad9$export$28c660c63b792dea = /*#__PURE__*/ (0, $4nVq8$forwardRef)(function Tooltip({ UNSTABLE_portalContainer: UNSTABLE_portalContainer, ...props }, ref) {
    [props, ref] = (0, $7230ffa83bc0c2cf$export$29f1550f4b0d4415)(props, ref, $05a50f7d78b03ad9$export$39ae08fa83328b12);
    let contextState = (0, $4nVq8$useContext)($05a50f7d78b03ad9$export$7a7623236eec67fa);
    let localState = (0, $4nVq8$useTooltipTriggerState)(props);
    let state = props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;
    let isExiting = (0, $4nVq8$useExitAnimation)(ref, state.isOpen) || props.isExiting || false;
    if (!state.isOpen && !isExiting) return null;
    return /*#__PURE__*/ (0, $4nVq8$react).createElement((0, $4nVq8$OverlayContainer), {
        portalContainer: UNSTABLE_portalContainer
    }, /*#__PURE__*/ (0, $4nVq8$react).createElement($05a50f7d78b03ad9$var$TooltipInner, {
        ...props,
        tooltipRef: ref,
        isExiting: isExiting
    }));
});
function $05a50f7d78b03ad9$var$TooltipInner(props) {
    let state = (0, $4nVq8$useContext)($05a50f7d78b03ad9$export$7a7623236eec67fa);
    let arrowRef = (0, $4nVq8$useRef)(null);
    let { overlayProps: overlayProps, arrowProps: arrowProps, placement: placement, triggerAnchorPoint: triggerAnchorPoint } = (0, $4nVq8$useOverlayPosition)({
        placement: props.placement || 'top',
        targetRef: props.triggerRef,
        overlayRef: props.tooltipRef,
        arrowRef: arrowRef,
        offset: props.offset,
        crossOffset: props.crossOffset,
        isOpen: state.isOpen,
        arrowBoundaryOffset: props.arrowBoundaryOffset,
        shouldFlip: props.shouldFlip,
        containerPadding: props.containerPadding,
        onClose: ()=>state.close(true)
    });
    let isEntering = (0, $4nVq8$useEnterAnimation)(props.tooltipRef, !!placement) || props.isEntering || false;
    let renderProps = (0, $7230ffa83bc0c2cf$export$4d86445c2cf5e3)({
        ...props,
        defaultClassName: 'react-aria-Tooltip',
        values: {
            placement: placement,
            isEntering: isEntering,
            isExiting: props.isExiting,
            state: state
        }
    });
    props = (0, $4nVq8$mergeProps)(props, overlayProps);
    let { tooltipProps: tooltipProps } = (0, $4nVq8$useTooltip)(props, state);
    let DOMProps = (0, $4nVq8$filterDOMProps)(props, {
        global: true
    });
    return /*#__PURE__*/ (0, $4nVq8$react).createElement((0, $7230ffa83bc0c2cf$export$df3a06d6289f983e).div, {
        ...(0, $4nVq8$mergeProps)(DOMProps, renderProps, tooltipProps),
        ref: props.tooltipRef,
        style: {
            ...overlayProps.style,
            '--trigger-anchor-point': triggerAnchorPoint ? `${triggerAnchorPoint.x}px ${triggerAnchorPoint.y}px` : undefined,
            ...renderProps.style
        },
        "data-placement": placement ?? undefined,
        "data-entering": isEntering || undefined,
        "data-exiting": props.isExiting || undefined
    }, /*#__PURE__*/ (0, $4nVq8$react).createElement((0, $4fcfe18fac72dabd$export$2de4954e8ae13b9f).Provider, {
        value: {
            ...arrowProps,
            placement: placement,
            ref: arrowRef
        }
    }, renderProps.children));
}


export {$05a50f7d78b03ad9$export$7a7623236eec67fa as TooltipTriggerStateContext, $05a50f7d78b03ad9$export$39ae08fa83328b12 as TooltipContext, $05a50f7d78b03ad9$export$8c610744efcf8a1d as TooltipTrigger, $05a50f7d78b03ad9$export$28c660c63b792dea as Tooltip};
//# sourceMappingURL=Tooltip.mjs.map
