"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.n = (module)=>{
        var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
        __webpack_require__.d(getter, {
            a: getter
        });
        return getter;
    };
})();
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    AutopilotChatTooltip: ()=>AutopilotChatTooltip
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const material_namespaceObject = require("@mui/material");
const apollo_core_namespaceObject = require("@uipath/apollo-core");
var apollo_core_default = /*#__PURE__*/ __webpack_require__.n(apollo_core_namespaceObject);
const external_react_namespaceObject = require("react");
var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
const chat_scroll_provider_cjs_namespaceObject = require("../../providers/chat-scroll-provider.cjs");
const chat_state_provider_cjs_namespaceObject = require("../../providers/chat-state-provider.cjs");
const AutopilotChatTooltip = /*#__PURE__*/ external_react_default().memo(({ title, disableInteractive = false, placement = 'bottom', children, open: controlledOpen, onOpen: controlledOnOpen, onClose: controlledOnClose, slotProps: customSlotProps, enterDelay, enterNextDelay })=>{
    const [internalOpen, setInternalOpen] = external_react_default().useState(false);
    const { overflowContainer } = (0, chat_scroll_provider_cjs_namespaceObject.useChatScroll)();
    const { portalContainer } = (0, chat_state_provider_cjs_namespaceObject.useChatState)();
    const tooltipRef = external_react_default().useRef(null);
    const isControlled = void 0 !== controlledOpen;
    const open = isControlled ? controlledOpen : internalOpen;
    external_react_default().useEffect(()=>{
        if (!overflowContainer || !open) return;
        const handleScroll = ()=>{
            if (isControlled) controlledOnClose?.();
            else setInternalOpen(false);
        };
        overflowContainer.addEventListener('scroll', handleScroll, {
            passive: true,
            capture: true
        });
        return ()=>{
            overflowContainer.removeEventListener('scroll', handleScroll, {
                capture: true
            });
        };
    }, [
        overflowContainer,
        open,
        isControlled,
        controlledOnClose
    ]);
    const handleTooltipClose = external_react_default().useCallback(()=>{
        if (isControlled) controlledOnClose?.();
        else setInternalOpen(false);
    }, [
        isControlled,
        controlledOnClose
    ]);
    const handleTooltipOpen = external_react_default().useCallback(()=>{
        if (isControlled) controlledOnOpen?.();
        else setInternalOpen(true);
    }, [
        isControlled,
        controlledOnOpen
    ]);
    const defaultSlotProps = external_react_default().useMemo(()=>({
            popper: {
                container: portalContainer
            },
            tooltip: {
                sx: {
                    maxWidth: '300px',
                    backgroundColor: 'var(--color-foreground)',
                    color: 'var(--color-background)',
                    padding: `${apollo_core_default().Spacing.SpacingXs} ${apollo_core_default().Spacing.SpacingS}`,
                    borderRadius: apollo_core_default().Border.BorderRadiusM,
                    fontSize: apollo_core_default().FontFamily.FontSSize,
                    lineHeight: apollo_core_default().FontFamily.FontSLineHeight,
                    '& > *': {
                        display: 'block',
                        marginBottom: apollo_core_default().Spacing.SpacingMicro,
                        '&:last-child': {
                            marginBottom: 0
                        }
                    }
                }
            }
        }), [
        portalContainer
    ]);
    const mergedSlotProps = external_react_default().useMemo(()=>customSlotProps ? {
            popper: {
                ...defaultSlotProps?.popper,
                ...customSlotProps.popper
            },
            tooltip: {
                ...defaultSlotProps?.tooltip,
                ...customSlotProps.tooltip
            }
        } : defaultSlotProps, [
        defaultSlotProps,
        customSlotProps
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(material_namespaceObject.Tooltip, {
        ref: tooltipRef,
        title: title,
        open: open,
        onClose: handleTooltipClose,
        onOpen: handleTooltipOpen,
        disableInteractive: disableInteractive,
        placement: placement,
        enterDelay: enterDelay,
        enterNextDelay: enterNextDelay,
        TransitionProps: {
            timeout: 0
        },
        slotProps: mergedSlotProps,
        children: children
    });
});
exports.AutopilotChatTooltip = __webpack_exports__.AutopilotChatTooltip;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "AutopilotChatTooltip"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
