var $048d76b84370f141$exports = require("./utils.cjs");
var $89c727392dd0ab84$exports = require("./OverlayArrow.cjs");
var $cQApC$reactariaprivateoverlaysuseOverlayPosition = require("react-aria/private/overlays/useOverlayPosition");
var $cQApC$reactariaprivateutilsfilterDOMProps = require("react-aria/private/utils/filterDOMProps");
var $cQApC$reactariaprivateinteractionsuseFocusable = require("react-aria/private/interactions/useFocusable");
var $cQApC$reactariamergeProps = require("react-aria/mergeProps");
var $cQApC$reactariaprivateoverlaysuseModal = require("react-aria/private/overlays/useModal");
var $cQApC$react = require("react");
var $cQApC$reactstatelyuseTooltipTriggerState = require("react-stately/useTooltipTriggerState");
var $cQApC$reactariaprivateutilsanimation = require("react-aria/private/utils/animation");
var $cQApC$reactariauseTooltipTrigger = require("react-aria/useTooltipTrigger");


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, "TooltipTriggerStateContext", function () { return $1f7d7e07fe5bbfc5$export$7a7623236eec67fa; });
$parcel$export(module.exports, "TooltipContext", function () { return $1f7d7e07fe5bbfc5$export$39ae08fa83328b12; });
$parcel$export(module.exports, "TooltipTrigger", function () { return $1f7d7e07fe5bbfc5$export$8c610744efcf8a1d; });
$parcel$export(module.exports, "Tooltip", function () { return $1f7d7e07fe5bbfc5$export$28c660c63b792dea; });
/*
 * 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 $1f7d7e07fe5bbfc5$export$7a7623236eec67fa = /*#__PURE__*/ (0, $cQApC$react.createContext)(null);
const $1f7d7e07fe5bbfc5$export$39ae08fa83328b12 = /*#__PURE__*/ (0, $cQApC$react.createContext)(null);
function $1f7d7e07fe5bbfc5$export$8c610744efcf8a1d(props) {
    let state = (0, $cQApC$reactstatelyuseTooltipTriggerState.useTooltipTriggerState)(props);
    let ref = (0, $cQApC$react.useRef)(null);
    let { triggerProps: triggerProps, tooltipProps: tooltipProps } = (0, $cQApC$reactariauseTooltipTrigger.useTooltipTrigger)(props, state, ref);
    return /*#__PURE__*/ (0, ($parcel$interopDefault($cQApC$react))).createElement((0, $048d76b84370f141$exports.Provider), {
        values: [
            [
                $1f7d7e07fe5bbfc5$export$7a7623236eec67fa,
                state
            ],
            [
                $1f7d7e07fe5bbfc5$export$39ae08fa83328b12,
                {
                    ...tooltipProps,
                    triggerRef: ref
                }
            ]
        ]
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($cQApC$react))).createElement((0, $cQApC$reactariaprivateinteractionsuseFocusable.FocusableProvider), {
        ...triggerProps,
        ref: ref
    }, props.children));
}
const $1f7d7e07fe5bbfc5$export$28c660c63b792dea = /*#__PURE__*/ (0, $cQApC$react.forwardRef)(function Tooltip({ UNSTABLE_portalContainer: UNSTABLE_portalContainer, ...props }, ref) {
    [props, ref] = (0, $048d76b84370f141$exports.useContextProps)(props, ref, $1f7d7e07fe5bbfc5$export$39ae08fa83328b12);
    let contextState = (0, $cQApC$react.useContext)($1f7d7e07fe5bbfc5$export$7a7623236eec67fa);
    let localState = (0, $cQApC$reactstatelyuseTooltipTriggerState.useTooltipTriggerState)(props);
    let state = props.isOpen != null || props.defaultOpen != null || !contextState ? localState : contextState;
    let isExiting = (0, $cQApC$reactariaprivateutilsanimation.useExitAnimation)(ref, state.isOpen) || props.isExiting || false;
    if (!state.isOpen && !isExiting) return null;
    return /*#__PURE__*/ (0, ($parcel$interopDefault($cQApC$react))).createElement((0, $cQApC$reactariaprivateoverlaysuseModal.OverlayContainer), {
        portalContainer: UNSTABLE_portalContainer
    }, /*#__PURE__*/ (0, ($parcel$interopDefault($cQApC$react))).createElement($1f7d7e07fe5bbfc5$var$TooltipInner, {
        ...props,
        tooltipRef: ref,
        isExiting: isExiting
    }));
});
function $1f7d7e07fe5bbfc5$var$TooltipInner(props) {
    let state = (0, $cQApC$react.useContext)($1f7d7e07fe5bbfc5$export$7a7623236eec67fa);
    let arrowRef = (0, $cQApC$react.useRef)(null);
    let { overlayProps: overlayProps, arrowProps: arrowProps, placement: placement, triggerAnchorPoint: triggerAnchorPoint } = (0, $cQApC$reactariaprivateoverlaysuseOverlayPosition.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, $cQApC$reactariaprivateutilsanimation.useEnterAnimation)(props.tooltipRef, !!placement) || props.isEntering || false;
    let renderProps = (0, $048d76b84370f141$exports.useRenderProps)({
        ...props,
        defaultClassName: 'react-aria-Tooltip',
        values: {
            placement: placement,
            isEntering: isEntering,
            isExiting: props.isExiting,
            state: state
        }
    });
    props = (0, $cQApC$reactariamergeProps.mergeProps)(props, overlayProps);
    let { tooltipProps: tooltipProps } = (0, $cQApC$reactariauseTooltipTrigger.useTooltip)(props, state);
    let DOMProps = (0, $cQApC$reactariaprivateutilsfilterDOMProps.filterDOMProps)(props, {
        global: true
    });
    return /*#__PURE__*/ (0, ($parcel$interopDefault($cQApC$react))).createElement((0, $048d76b84370f141$exports.dom).div, {
        ...(0, $cQApC$reactariamergeProps.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, ($parcel$interopDefault($cQApC$react))).createElement((0, $89c727392dd0ab84$exports.OverlayArrowContext).Provider, {
        value: {
            ...arrowProps,
            placement: placement,
            ref: arrowRef
        }
    }, renderProps.children));
}


//# sourceMappingURL=Tooltip.cjs.map
