'use strict';

var jsxRuntime = require('../../node_modules/.pnpm/react@18.2.0/node_modules/react/jsx-runtime.cjs');
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 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@18.0.11_@types_react@18.2.12_react-dom@18.3.1_react@18.2.0__react@18.2.0/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 Tooltip = ({ children, message, disabled, side = 'top', classNames, triggerStyle, contentStyle, delayDuration = 200, skipDelayDuration = 200, 'aria-label': ariaLabel, asChild = true, showArrow = true, id, followCursor = false, sideOffset = 4, alignOffset = 0 }) => {
    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.jsxRuntimeExports.jsx(index.Provider, { delayDuration: delayDuration, skipDelayDuration: skipDelayDuration, children: jsxRuntime.jsxRuntimeExports.jsxs(index.Root, { children: [jsxRuntime.jsxRuntimeExports.jsx(index.Trigger, { "aria-describedby": tooltipId, asChild: asChild, onFocus: followCursor ? reset : undefined, children: jsxRuntime.jsxRuntimeExports.jsx("div", { ref: ref, className: index$1.cx(tooltip_module.default.trigger, classNames?.trigger), style: triggerStyle, children: children }) }), jsxRuntime.jsxRuntimeExports.jsx(index.Portal, { children: jsxRuntime.jsxRuntimeExports.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
                        }, children: [typeof message === 'string' ? jsxRuntime.jsxRuntimeExports.jsx(text.Text, { children: message }) : message, showArrow && (jsxRuntime.jsxRuntimeExports.jsx(index.Arrow, { className: index$1.cx(tooltip_module.default.arrow, classNames?.arrow), width: 7, height: 7 }))] }) })] }) }));
};
Tooltip.displayName = 'Tooltip';
const TooltipProvider = index.Provider;

exports.Tooltip = Tooltip;
exports.TooltipProvider = TooltipProvider;
//# sourceMappingURL=tooltip.cjs.map
