"use client";
'use strict';

var jsxRuntime = require('react/jsx-runtime');
var index$1 = require('../../node_modules/.pnpm/class-variance-authority@0.7.1/node_modules/class-variance-authority/dist/index.cjs');
var React = require('react');
var useMouse = require('../../hooks/useMouse.cjs');
var text = require('../text/text.cjs');
var tooltipProvider = require('./tooltip-provider.cjs');
var tooltip_module = require('./tooltip.module.css.cjs');
var utils = require('./utils.cjs');
var index = require('../../node_modules/.pnpm/@radix-ui_react-tooltip@1.2.7_@types_react-dom@19.1.7_@types_react@19.1.9__@types_react@19.1._dc3knlq5xr3bsp42ltsj4iesx4/node_modules/@radix-ui/react-tooltip/dist/index.cjs');

const tooltip = index$1.cva(tooltip_module.default.content, {
    variants: {
        side: {
            top: tooltip_module.default['side-top'],
            right: tooltip_module.default['side-right'],
            bottom: tooltip_module.default['side-bottom'],
            left: tooltip_module.default['side-left'],
            'top-left': tooltip_module.default['side-top-left'],
            'top-right': tooltip_module.default['side-top-right'],
            'bottom-left': tooltip_module.default['side-bottom-left'],
            'bottom-right': tooltip_module.default['side-bottom-right']
        }
    },
    defaultVariants: {
        side: 'top'
    }
});
const TooltipBase = ({ children, message, disabled, side = 'top', classNames, triggerStyle, contentStyle, 'aria-label': ariaLabel, asChild = true, showArrow = true, id, followCursor = false, sideOffset = 4, alignOffset = 0, open, defaultOpen, delayDuration = 200, onOpenChange, disableHoverableContent, ...props }) => {
    const generatedId = React.useId();
    const tooltipId = id ?? generatedId;
    const { ref, value: mouseValue, reset } = useMouse.useMouse({
        resetOnExit: false,
        enabled: followCursor
    });
    const computedSide = React.useMemo(() => (side?.split('-')[0] || 'top'), [side]);
    const computedAlign = React.useMemo(() => (side?.includes('-')
        ? side.split('-')[1] === 'left'
            ? 'start'
            : 'end'
        : 'center'), [side]);
    if (disabled)
        return children;
    return (jsxRuntime.jsxs(index.Root, { open: open, defaultOpen: defaultOpen, onOpenChange: onOpenChange, delayDuration: delayDuration, disableHoverableContent: disableHoverableContent, children: [jsxRuntime.jsx(index.Trigger, { "aria-describedby": tooltipId, asChild: asChild, onFocus: followCursor ? reset : undefined, children: jsxRuntime.jsx("div", { ref: ref, className: index$1.cx(tooltip_module.default.trigger, classNames?.trigger), style: triggerStyle, children: children }) }), jsxRuntime.jsx(index.Portal, { children: jsxRuntime.jsxs(index.Content, { id: tooltipId, role: 'tooltip', "aria-label": ariaLabel || (typeof message === 'string' ? message : undefined), side: computedSide, align: computedAlign, alignOffset: alignOffset, sideOffset: sideOffset, className: tooltip({ side, className: classNames?.content }), "data-follow-cursor": followCursor, style: {
                        ...contentStyle,
                        pointerEvents: followCursor ? 'none' : undefined,
                        transform: followCursor && mouseValue
                            ? utils.getTransformForPlacement(computedSide, computedAlign, mouseValue)
                            : undefined
                    }, ...props, children: [typeof message === 'string' ? jsxRuntime.jsx(text.Text, { children: message }) : message, showArrow && (jsxRuntime.jsx(index.Arrow, { className: index$1.cx(tooltip_module.default.arrow, classNames?.arrow), width: 7, height: 7 }))] }) })] }));
};
const TooltipRoot = (props) => {
    const provider = tooltipProvider.useTooltipProvider();
    // If already inside a provider, just return the tooltip
    if (provider)
        return jsxRuntime.jsx(TooltipBase, { ...props });
    // If not inside a provider, wrap with our own provider
    return (jsxRuntime.jsx(tooltipProvider.TooltipProvider, { children: jsxRuntime.jsx(TooltipBase, { ...props }) }));
};
TooltipRoot.displayName = 'TooltipRoot';

exports.TooltipBase = TooltipBase;
exports.TooltipRoot = TooltipRoot;
//# sourceMappingURL=tooltip-root.cjs.map
