"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__, {
    HierarchicalCanvasWithControls: ()=>HierarchicalCanvasWithControls
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const react_cjs_namespaceObject = require("../../xyflow/react.cjs");
const apollo_wind_namespaceObject = require("@uipath/apollo-wind");
const external_react_namespaceObject = require("react");
const index_cjs_namespaceObject = require("../../core/index.cjs");
const canvasStore_cjs_namespaceObject = require("../../stores/canvasStore.cjs");
const icon_registry_cjs_namespaceObject = require("../../utils/icon-registry.cjs");
const external_HierarchicalCanvas_cjs_namespaceObject = require("./HierarchicalCanvas.cjs");
const createDemoCanvases = ()=>{
    const rootCanvas = {
        id: 'root',
        name: 'Main Workflow',
        nodes: [
            {
                type: 'blank-canvas-node',
                position: {
                    x: 500,
                    y: 500
                },
                id: 'blank-canvas-node',
                data: {
                    label: 'Start Here'
                }
            }
        ],
        edges: [],
        nodeTypes: [
            'default'
        ],
        edgeTypes: [
            'default'
        ],
        viewport: {
            x: 0,
            y: 0,
            zoom: 1
        },
        selection: {
            isSingleNodeSelected: false,
            isSingleEdgeSelected: false,
            nodeIds: [],
            edgeIds: []
        },
        options: {},
        properties: {}
    };
    return {
        root: rootCanvas
    };
};
const workflowCategories = [
    {
        id: 'Basic',
        name: 'Basic',
        sortOrder: 0,
        color: 'linear-gradient(135deg, #FAFAFB 0%, #ECEDEF 100%)',
        colorDark: 'linear-gradient(135deg, #526069 0%, rgba(50, 60, 66, 0.6) 100%)',
        icon: 'boxes',
        tags: [
            'basic',
            'fundamental'
        ]
    },
    {
        id: 'Actions',
        name: 'Actions',
        sortOrder: 1,
        color: 'linear-gradient(135deg, #FAFAFB 0%, #ECEDEF 100%)',
        colorDark: 'linear-gradient(135deg, #526069 0%, rgba(50, 60, 66, 0.6) 100%)',
        icon: 'zap',
        tags: [
            'action',
            'activity'
        ]
    },
    {
        id: 'Logic',
        name: 'Logic',
        sortOrder: 2,
        color: 'linear-gradient(135deg, #FAFAFB 0%, #ECEDEF 100%)',
        colorDark: 'linear-gradient(135deg, #526069 0%, rgba(50, 60, 66, 0.6) 100%)',
        icon: 'workflow',
        tags: [
            'logic',
            'decision'
        ]
    },
    {
        id: 'Structure',
        name: 'Structure',
        sortOrder: 3,
        color: 'linear-gradient(135deg, #FAFAFB 0%, #ECEDEF 100%)',
        colorDark: 'linear-gradient(135deg, #526069 0%, rgba(50, 60, 66, 0.6) 100%)',
        icon: 'layers',
        tags: [
            'structure',
            'organization'
        ]
    }
];
const workflowManifests = [
    {
        nodeType: 'start',
        version: '1.0.0',
        category: 'Basic',
        tags: [
            'workflow',
            'basic'
        ],
        sortOrder: 1,
        display: {
            label: 'Start',
            icon: 'circle-play',
            shape: 'circle'
        },
        handleConfiguration: [
            {
                position: 'right',
                handles: [
                    {
                        id: 'output',
                        type: 'source',
                        handleType: 'output',
                        showButton: true
                    }
                ]
            }
        ]
    },
    {
        nodeType: 'end',
        version: '1.0.0',
        category: 'Basic',
        tags: [
            'workflow',
            'basic'
        ],
        sortOrder: 2,
        display: {
            label: 'End',
            icon: 'circle-stop',
            shape: 'circle'
        },
        handleConfiguration: [
            {
                position: 'left',
                handles: [
                    {
                        id: 'input',
                        type: 'target',
                        handleType: 'input'
                    }
                ]
            }
        ]
    },
    {
        nodeType: 'process',
        version: '1.0.0',
        category: 'Actions',
        tags: [
            'workflow',
            'action'
        ],
        sortOrder: 10,
        display: {
            label: 'Process',
            icon: 'settings',
            shape: 'rectangle'
        },
        handleConfiguration: [
            {
                position: 'left',
                handles: [
                    {
                        id: 'input',
                        type: 'target',
                        handleType: 'input'
                    }
                ]
            },
            {
                position: 'right',
                handles: [
                    {
                        id: 'output',
                        type: 'source',
                        handleType: 'output',
                        showButton: true
                    }
                ]
            }
        ]
    },
    {
        nodeType: 'decision',
        version: '1.0.0',
        category: 'Logic',
        tags: [
            'workflow',
            'logic'
        ],
        sortOrder: 20,
        display: {
            label: 'Decision',
            icon: 'split',
            shape: 'square'
        },
        handleConfiguration: [
            {
                position: 'left',
                handles: [
                    {
                        id: 'input',
                        type: 'target',
                        handleType: 'input'
                    }
                ]
            },
            {
                position: 'right',
                handles: [
                    {
                        id: 'output-true',
                        type: 'source',
                        handleType: 'output',
                        label: 'True',
                        showButton: true
                    },
                    {
                        id: 'output-false',
                        type: 'source',
                        handleType: 'output',
                        label: 'False',
                        showButton: true
                    }
                ]
            }
        ]
    },
    {
        nodeType: 'subprocess',
        version: '1.0.0',
        category: 'Structure',
        tags: [
            'workflow',
            'structure'
        ],
        sortOrder: 40,
        display: {
            label: 'Sub-Process',
            icon: 'folder',
            shape: 'square'
        },
        handleConfiguration: [
            {
                position: 'left',
                handles: [
                    {
                        id: 'input',
                        type: 'target',
                        handleType: 'input'
                    }
                ]
            },
            {
                position: 'right',
                handles: [
                    {
                        id: 'output',
                        type: 'source',
                        handleType: 'output',
                        showButton: true
                    }
                ]
            }
        ],
        toolbarExtensions: {
            design: {
                actions: [
                    {
                        id: 'drill-in',
                        icon: 'external-link',
                        label: 'Open Sub-Process'
                    }
                ]
            }
        }
    }
];
const workflowManifest = {
    version: '1.0.0',
    categories: workflowCategories,
    nodes: workflowManifests
};
const CanvasWithControlsContent = ({ initialCanvases, initialPath, onCanvasesChange, onPathChange })=>{
    const currentCanvas = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectCurrentCanvas);
    const currentPathLength = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectCurrentPathLength);
    const addNode = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectAddNode);
    const removeNode = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectRemoveNode);
    const removeEdge = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectRemoveEdge);
    const updateNodes = (0, canvasStore_cjs_namespaceObject.useCanvasStore)(canvasStore_cjs_namespaceObject.selectUpdateNodes);
    const handleAddNode = (0, external_react_namespaceObject.useCallback)((nodeType)=>{
        const existingNodes = currentCanvas?.nodes.filter((n)=>'blank-canvas-node' !== n.id).length || 0;
        const position = {
            x: 200 + existingNodes % 3 * 250,
            y: 200 + 200 * Math.floor(existingNodes / 3)
        };
        const blankNode = currentCanvas?.nodes.find((n)=>'blank-canvas-node' === n.id);
        if (blankNode) removeNode('blank-canvas-node');
        addNode(nodeType, position);
    }, [
        addNode,
        removeNode,
        currentCanvas
    ]);
    const handleAddSampleWorkflow = (0, external_react_namespaceObject.useCallback)(()=>{
        if (currentCanvas?.nodes) currentCanvas.nodes.forEach((node)=>{
            removeNode(node.id);
        });
        const nodes = [
            {
                type: 'start',
                position: {
                    x: 100,
                    y: 100
                }
            },
            {
                type: 'subprocess',
                position: {
                    x: 300,
                    y: 100
                }
            },
            {
                type: 'decision',
                position: {
                    x: 500,
                    y: 100
                }
            },
            {
                type: 'subprocess',
                position: {
                    x: 600,
                    y: 250
                }
            },
            {
                type: 'end',
                position: {
                    x: 700,
                    y: 100
                }
            }
        ];
        nodes.forEach((node, index)=>{
            setTimeout(()=>{
                addNode(node.type, node.position);
            }, 100 * index);
        });
    }, [
        addNode,
        removeNode,
        currentCanvas
    ]);
    const handleClearCanvas = (0, external_react_namespaceObject.useCallback)(()=>{
        if (currentCanvas?.nodes) currentCanvas.nodes.forEach((node)=>{
            removeNode(node.id);
        });
        if (currentCanvas?.edges) currentCanvas.edges.forEach((edge)=>{
            removeEdge(edge.id);
        });
        const blankNode = {
            id: 'blank-canvas-node',
            type: 'blank-canvas-node',
            position: {
                x: 0,
                y: 0
            },
            data: {}
        };
        updateNodes([
            blankNode
        ]);
    }, [
        removeNode,
        removeEdge,
        updateNodes,
        currentCanvas
    ]);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
        style: {
            width: '100%',
            height: '100vh',
            position: 'relative'
        },
        children: [
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_HierarchicalCanvas_cjs_namespaceObject.HierarchicalCanvas, {
                mode: "design",
                initialCanvases: initialCanvases,
                initialPath: initialPath,
                onCanvasesChange: onCanvasesChange,
                onPathChange: onPathChange
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_cjs_namespaceObject.Panel, {
                position: "center-right",
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                    style: {
                        display: 'flex',
                        flexDirection: 'column',
                        gap: '8px',
                        padding: '8px',
                        backgroundColor: 'var(--canvas-background)',
                        borderRadius: '8px',
                        boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
                        minWidth: '180px'
                    },
                    children: [
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
                            variant: "secondary",
                            size: "sm",
                            onClick: ()=>handleAddNode('start'),
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                                    icon: "circle-play",
                                    size: 16
                                }),
                                " Start"
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
                            variant: "secondary",
                            size: "sm",
                            onClick: ()=>handleAddNode('process'),
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                                    icon: "settings",
                                    size: 16
                                }),
                                " Process"
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
                            variant: "secondary",
                            size: "sm",
                            onClick: ()=>handleAddNode('decision'),
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                                    icon: "circle-question-mark",
                                    size: 16
                                }),
                                " Decision"
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
                            variant: "secondary",
                            size: "sm",
                            onClick: ()=>handleAddNode('subprocess'),
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                                    icon: "folder",
                                    size: 16
                                }),
                                " Sub-Process"
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
                            variant: "secondary",
                            size: "sm",
                            onClick: ()=>handleAddNode('end'),
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                                    icon: "circle-stop",
                                    size: 16
                                }),
                                " End"
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
                            size: "sm",
                            onClick: handleAddSampleWorkflow,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                                    icon: "sparkles",
                                    size: 16
                                }),
                                " Sample Workflow"
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(apollo_wind_namespaceObject.Button, {
                            variant: "secondary",
                            size: "sm",
                            onClick: handleClearCanvas,
                            children: [
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(icon_registry_cjs_namespaceObject.CanvasIcon, {
                                    icon: "x",
                                    size: 16
                                }),
                                " Clear Canvas"
                            ]
                        })
                    ]
                })
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_cjs_namespaceObject.Panel, {
                position: "top-right",
                children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                    style: {
                        padding: '12px',
                        color: 'var(--canvas-foreground)',
                        backgroundColor: 'var(--canvas-background)',
                        borderRadius: '8px',
                        boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
                        fontSize: '12px'
                    },
                    children: [
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                            className: "text-sm font-bold",
                            children: "Canvas Info"
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            children: [
                                "Nodes: ",
                                currentCanvas?.nodes?.length || 0
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            children: [
                                "Edges: ",
                                currentCanvas?.edges?.length || 0
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            children: [
                                "Level: ",
                                currentPathLength
                            ]
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                            className: "text-sm font-bold",
                            children: "Instructions"
                        }),
                        /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
                            style: {
                                fontSize: '11px',
                                lineHeight: '1.4'
                            },
                            children: [
                                "1. Add nodes or drag to create",
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("br", {}),
                                "2. Click + button on handles",
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("br", {}),
                                "3. Connect nodes",
                                /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("br", {}),
                                "4. Double-click Sub-Process to drill in"
                            ]
                        })
                    ]
                })
            })
        ]
    });
};
const HierarchicalCanvasWithControls = ()=>{
    const [initialCanvases] = (0, external_react_namespaceObject.useState)(()=>createDemoCanvases());
    const [initialPath] = (0, external_react_namespaceObject.useState)([
        'root'
    ]);
    const handleCanvasesChange = (0, external_react_namespaceObject.useCallback)((canvases)=>{
        console.log('Canvas data changed:', Object.keys(canvases));
    }, []);
    const handlePathChange = (0, external_react_namespaceObject.useCallback)((path)=>{
        console.log('Navigation path changed:', path);
    }, []);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_cjs_namespaceObject.NodeRegistryProvider, {
        manifest: workflowManifest,
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_cjs_namespaceObject.ReactFlowProvider, {
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CanvasWithControlsContent, {
                initialCanvases: initialCanvases,
                initialPath: initialPath,
                onCanvasesChange: handleCanvasesChange,
                onPathChange: handlePathChange
            })
        })
    });
};
exports.HierarchicalCanvasWithControls = __webpack_exports__.HierarchicalCanvasWithControls;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "HierarchicalCanvasWithControls"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
