"use strict";
var __webpack_require__ = {};
(()=>{
    __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__, {
    TriggerNode: ()=>TriggerNode
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
const external_react_namespaceObject = require("react");
const icon_registry_cjs_namespaceObject = require("../../utils/icon-registry.cjs");
const ConnectedHandlesContext_cjs_namespaceObject = require("../BaseCanvas/ConnectedHandlesContext.cjs");
const useButtonHandles_cjs_namespaceObject = require("../ButtonHandle/useButtonHandles.cjs");
const external_CanvasTooltip_cjs_namespaceObject = require("../CanvasTooltip.cjs");
const external_TriggerNode_styles_cjs_namespaceObject = require("./TriggerNode.styles.cjs");
const TriggerNodeComponent = (props)=>{
    const { selected, id, details = {} } = props;
    const { tooltip, icon, status } = details;
    const [isHovered, setIsHovered] = (0, external_react_namespaceObject.useState)(false);
    const isConnecting = (0, react_cjs_namespaceObject.useStore)((state)=>!!state.connectionClickStartHandle);
    const connectedHandleIds = (0, ConnectedHandlesContext_cjs_namespaceObject.useConnectedHandles)(id);
    const hasConnections = connectedHandleIds.size > 0;
    const shouldShowHandles = (0, external_react_namespaceObject.useMemo)(()=>selected || isHovered || isConnecting || hasConnections, [
        selected,
        isHovered,
        isConnecting,
        hasConnections
    ]);
    const handleMouseEnter = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(true), []);
    const handleMouseLeave = (0, external_react_namespaceObject.useCallback)(()=>setIsHovered(false), []);
    const handleConfigurations = [
        {
            position: react_cjs_namespaceObject.Position.Right,
            handles: [
                {
                    id: `${id}____source____right`,
                    type: 'source',
                    handleType: 'output'
                }
            ],
            visible: selected || isHovered || isConnecting
        }
    ];
    const handleElements = (0, useButtonHandles_cjs_namespaceObject.useButtonHandles)({
        handleConfigurations,
        shouldShowHandles,
        nodeId: id,
        selected
    });
    const triggerContent = /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_TriggerNode_styles_cjs_namespaceObject.TriggerContainer, {
        selected: !!selected,
        status: status,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_TriggerNode_styles_cjs_namespaceObject.TriggerIconWrapper, {
            status: status,
            children: icon || /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                icon: "zap"
            })
        })
    });
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        style: {
            width: '100%',
            height: '100%',
            position: 'relative'
        },
        onMouseEnter: handleMouseEnter,
        onMouseLeave: handleMouseLeave,
        children: [
            tooltip ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
                content: tooltip,
                placement: "top",
                children: triggerContent
            }) : triggerContent,
            handleElements
        ]
    });
};
const TriggerNode = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(TriggerNodeComponent);
exports.TriggerNode = __webpack_exports__.TriggerNode;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "TriggerNode"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
