"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__, {
    BlankCanvasNode: ()=>BlankCanvasNode
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
const external_react_namespaceObject = require("react");
const canvasStore_cjs_namespaceObject = require("../../stores/canvasStore.cjs");
const icon_registry_cjs_namespaceObject = require("../../utils/icon-registry.cjs");
const index_cjs_namespaceObject = require("../AddNodePanel/index.cjs");
const external_FloatingCanvasPanel_index_cjs_namespaceObject = require("../FloatingCanvasPanel/index.cjs");
const external_BlankCanvasNode_styles_cjs_namespaceObject = require("./BlankCanvasNode.styles.cjs");
const BlankCanvasNode = (props)=>{
    const nodeRef = (0, external_react_namespaceObject.useRef)(null);
    const removeNode = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectRemoveNode);
    const addNode = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectAddNode);
    const storeApi = (0, react_cjs_namespaceObject.useStoreApi)();
    const { id, selected, positionAbsoluteX, positionAbsoluteY, data } = props;
    const { label } = data;
    const handleClosePanel = (0, external_react_namespaceObject.useCallback)(()=>{
        storeApi.getState().resetSelectedElements();
    }, [
        storeApi
    ]);
    const handleNodeSelect = (0, external_react_namespaceObject.useCallback)((nodeItemData)=>{
        const position = {
            x: positionAbsoluteX,
            y: positionAbsoluteY
        };
        removeNode(id);
        addNode(nodeItemData.type, position);
    }, [
        id,
        removeNode,
        addNode,
        positionAbsoluteX,
        positionAbsoluteY
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_BlankCanvasNode_styles_cjs_namespaceObject.NodeContainer, {
                selected: selected,
                ref: nodeRef,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_BlankCanvasNode_styles_cjs_namespaceObject.IconWrapper, {
                    children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                        icon: "plus",
                        size: 48,
                        color: "var(--canvas-foreground-de-emp)"
                    })
                })
            }),
            'string' == typeof label && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_BlankCanvasNode_styles_cjs_namespaceObject.TextContainer, {
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_BlankCanvasNode_styles_cjs_namespaceObject.Header, {
                    children: label
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_FloatingCanvasPanel_index_cjs_namespaceObject.FloatingCanvasPanel, {
                open: selected,
                nodeId: id,
                placement: "right-start",
                offset: 20,
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.AddNodePanel, {
                    onNodeSelect: (item)=>handleNodeSelect(item.data),
                    onClose: handleClosePanel
                })
            })
        ]
    });
};
exports.BlankCanvasNode = __webpack_exports__.BlankCanvasNode;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "BlankCanvasNode"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
