/// <reference types="react" />
import { HandleType, Node as Node$1, Edge as Edge$1, NodeChange, EdgeChange, Connection, XYPosition } from 'reactflow';
import { SvgIconProps } from '@mui/material/SvgIcon';
import React$1, { Dispatch, SetStateAction, MutableRefObject } from 'react';

declare const DataTypes: Record<string, any>;

declare function addNewType(type: string, options: any): void;
declare function isDataTypeMatch(type1: string, type2: string): boolean;
declare const getMaxConnection: (handletype: HandleType, type: string) => number;

interface BasicNodeData {
    tooltip?: string;
    configType?: string;
}
type Node = Node$1<any, string | undefined>;

interface Handle {
    title?: string;
    connection?: number;
    tooltip?: string;
    dataType?: string;
    defaultValue?: any;
    value?: any;
}

interface HandleConfig {
    title?: string;
    dataType?: string;
    defaultValue?: any;
    tooltip?: string;
}
interface NodeConfig {
    category: string;
    title?: string;
    inputs?: Record<string, HandleConfig>;
    outputs?: Record<string, HandleConfig>;
    tooltip?: string;
    [key: string]: any;
    dataType?: string;
    enable?: boolean;
}
interface NodePackage {
    isPackage: true;
    nodes: Record<string, NodeConfig | NodePackage>;
    notShowInMenu?: boolean;
    tooltip?: string;
    href?: string;
    description?: string;
    type: string;
    enable?: boolean;
}
interface GraphNodeConfig extends NodeConfig {
    id: string;
    type: string;
    position: {
        x: number;
        y: number;
    };
    inputs?: Record<string, Handle>;
    outputs?: Record<string, Handle>;
}
interface GraphEdgeConfig {
    id: string;
    input: string;
    output: string;
    inputHandle: string;
    outputHandle: string;
    dataType?: string;
}
interface SerializedHandle {
    value?: any;
    [key: string]: any;
}
interface SerializedGraphNode {
    id: string;
    type: string;
    position: {
        x: number;
        y: number;
    };
    inputs?: Record<string, SerializedHandle>;
    outputs?: Record<string, SerializedHandle>;
    [key: string]: any;
}
type SerializedGraphEdge = GraphEdgeConfig;

interface ConnectableData extends BasicNodeData {
    title: string;
    inputs?: Record<string, Handle>;
    outputs?: Record<string, Handle>;
    dataType?: string;
}

interface VariableNodeData extends ConnectableData {
    isConstant?: boolean;
    dataType: string;
}

interface EdgeData extends BasicNodeData {
    dataType?: string;
}
type Edge = Edge$1<EdgeData>;

interface SerializedGraph {
    nodes: SerializedGraphNode[];
    edges: SerializedGraphEdge[];
}
interface Graph {
    nodes: Node[];
    edges: Edge[];
}

interface Comment extends BasicNodeData {
    comment: string;
    width?: number;
    height?: number;
}
declare function isCommentNode(nodeData: BasicNodeData): boolean;

interface StickyNote extends BasicNodeData {
    stickyNote: string;
    width?: number;
    height?: number;
}

interface ClipboardInfo {
    hasNodes: boolean;
    nodes: Record<string, Node>;
    edges: Edge[];
    minX: number;
    minY: number;
}

interface MousePos {
    mouseX: number;
    mouseY: number;
}

declare enum ConnectionAction {
    Reject = "reject",
    Allowed = "allowed",
    Replace = "replace"
}
interface ConnectionStatus {
    action: ConnectionAction;
    message?: string;
}

interface selectedElementsCounts {
    nodesCount: number;
    edgesCount: number;
}

interface IMouseTracker {
    mousePos: React.MutableRefObject<MousePos>;
    updateMousePos: (clientX: number, clientY: number) => void;
}
declare function useTrackMousePos(domRef: React.RefObject<HTMLDivElement>): IMouseTracker;

type OnChange<ChangesType> = (changes: ChangesType[]) => void;
interface GraphState {
    nodes: Node[];
    edges: Edge[];
    getFreeUniqueNodeIds: (count: number) => string[];
    setNodes: (nodes: Node[]) => void;
    onNodesChange: OnChange<NodeChange>;
    setEdges: (edges: Edge[]) => void;
    onEdgesChange: OnChange<EdgeChange>;
    onConnect: (params: Connection) => void;
    isValidConnection: (params: Connection) => ConnectionStatus;
    selectedNodes: () => Node[];
    getSelectedCounts: () => selectedElementsCounts;
    setSelectedCounts: (newCounts: selectedElementsCounts) => void;
    selectAll: (sure: boolean) => void;
    selectNode: (nodeId: string) => void;
    selectEdge: (edgeId: string) => void;
    clearEdgeSelection: () => void;
    clear: () => void;
    deleteSelectedNodes: () => void;
    deleteSelectedElements: () => void;
    deleteEdge: (id: string) => void;
    deleteAllEdgesOfNode: (nodeId: string) => void;
    deleteAllEdgesOfSelectedNodes: () => void;
    deleteAllEdgesOfHandle: (nodeId: string, handleId: string) => void;
    addElements: ({ newNodes, newEdges, }: {
        newNodes?: Node[];
        newEdges?: Edge[];
    }) => void;
    getHandleConnectionCounts: (nodeId: string, handleId: string) => number;
    anyConnectableNodeSelected: boolean;
    anyConnectionToSelectedNode: boolean;
    toString: () => string;
    fromJSON: (graph: SerializedGraph | undefined | null) => {
        nodes: Node[];
        edges: Edge[];
    };
}
declare function useGraph(graph?: SerializedGraph | null): GraphState;

interface Command {
    name: string;
    action: () => void;
    labelIcon?: React.ElementType<SvgIconProps> | undefined;
    labelInfo?: string;
    tooltip?: string;
}
interface Gui {
    showNodeMenu: boolean;
    showEdgeMenu: boolean;
    showHandleMenu: boolean;
    showSearchMenu: boolean;
    showConnectionTip: boolean;
    connectionStatus: ConnectionStatus | undefined;
    setconnectionStatus: Dispatch<SetStateAction<ConnectionStatus | undefined>>;
    openWidget: (menu: string) => void;
    closeWidget: () => void;
    clickedHandle: React.MutableRefObject<{
        connection: number;
        id: string;
    } | null>;
    clickedNodeId: React.MutableRefObject<string | null>;
    PosiontOnGui: {
        top: number;
        left: number;
    };
    setPosiontOnGui: (PosiontOnGui: {
        top: number;
        left: number;
    }) => void;
    connectionStartNodeId: MutableRefObject<string | null>;
}
declare function useGui(): Gui;

interface ISceneActions {
    getSelectedCounts: () => selectedElementsCounts;
    setSelectedCounts: (newCounts: selectedElementsCounts) => void;
    selectAll: (sure: boolean) => void;
    selectEdge: (edgeId: string) => void;
    selectNode: (nodeId: string) => void;
    addNode: (configType: string, thisPosition?: XYPosition) => Node;
    addEdge: (source: string, sourceHandle: string, target: string, targetHandle: string, dataType?: string) => void;
    clearEdgeSelection: () => void;
    getHandleConnectionCounts: (nodeId: string, handleId: string) => number;
    onNodeDragStart: (evt: any, node: Node) => void;
    onNodeDragStop: (evt: any, node: Node) => void;
    copySelectedNodeToClipboard: () => void;
    pasteFromClipboard: (notUseMousePos?: boolean) => void;
    deleteSelectedElements: () => void;
    duplicateSelectedNodes: (notUseMousePos?: boolean) => void;
    cutSelectedNodesToClipboard: () => void;
    clear: () => void;
    deleteEdge: (id: string) => void;
    deleteAllEdgesOfNode: (nodeId: string) => void;
    deleteAllEdgesOfHandle: (nodeId: string, handleId: string) => void;
    deleteAllEdgesOfSelectedNodes: () => void;
    isValidConnection: (params: any) => ConnectionStatus;
    centerSelectedNodes: () => void;
}
interface ISceneState {
    graphStateRef: React.MutableRefObject<GraphState>;
    anyConnectableNodeSelected: boolean;
    anyConnectionToSelectedNode: boolean;
    extraCommands: Command[];
    sceneActions: ISceneActions;
}
declare function useScene(graphState: GraphState, mousePos: React.MutableRefObject<{
    mouseX: number;
    mouseY: number;
}>): ISceneState;

declare function useKeyDown(sceneState?: ISceneState): {
    onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
};

interface IVPEditorOption {
    controller?: {
        hidden?: boolean;
    };
}
declare function VPEditor({ id, content, onContentChange, activated, onSceneActionsInit, onSelectionChange, option, }: {
    id: string;
    content?: SerializedGraph | null;
    onContentChange?: (content: string) => void;
    activated?: boolean;
    onSceneActionsInit?: (actions: ISceneActions) => void;
    onSelectionChange?: (counts: selectedElementsCounts) => void;
    option?: IVPEditorOption;
}): JSX.Element;

interface INodeModule {
    nodes?: Record<string, NodeConfig | NodePackage>;
    types?: Record<string, any>;
    notShowInMenu?: boolean;
    href?: string;
    description?: string;
    enable?: boolean;
}
declare const ParseModule: (m: INodeModule, relativePath: string) => any;
interface INodePackageDir {
    isPackage: boolean;
    subpackages?: Record<string, INodeModule | INodePackageDir>;
    enable?: boolean;
}
declare const LoadPackageToRegistry: (name: string, pkg: INodeModule | INodePackageDir) => void;
declare const LoadDefaultModule: () => void;

type config = NodeConfig | NodePackage;
declare class NodeConfigRegistry {
    private static instance;
    private readonly registry;
    private constructor();
    static getInstance(): NodeConfigRegistry;
    registerNodeConfig(name: string, node: config): void;
    getAllNodeConfigs(): Record<string, config>;
    getNodeConfig(name: string): NodeConfig;
    removeNodeConfig(name: string): void;
    enableNodeConfig(name: string, enable: boolean): void;
}
declare const nodeConfigRegistry: NodeConfigRegistry;

declare class WidgetFactory {
    private static instance;
    private readonly defaultWidgetProps;
    private readonly _availableWidgets;
    private constructor();
    static getInstance(): WidgetFactory;
    get availableWidgets(): Record<string, JSX.Element>;
    registerWidget(widgetType: string, widget: JSX.Element): void;
    createWidget(type: string, widgetOptions: any): JSX.Element;
}
declare const widgetFactory: WidgetFactory;

declare function InPlaceTextArea({ text, initialRow, onStartEdit, onStopEdit, onEditChange, }: {
    text?: string;
    initialRow?: number;
    onStartEdit?: () => void;
    onStopEdit?: () => void;
    onEditChange?: (text: string) => void;
}): JSX.Element;

declare function InPlaceInput({ text, onStartEdit, onStopEdit, onEditChange, }: {
    text?: string;
    onStartEdit?: () => void;
    onStopEdit?: () => void;
    onEditChange?: (text: string) => void;
}): JSX.Element;

declare function NodeMenu({ open, onClose, anchorPosition, onDelete, onCut, onCopy, onDuplicate, anyConnectableNodeSelected, anyConnectionToSelectedNode, onBreakNodeLinks, }: {
    open: boolean;
    onClose: () => void;
    anchorPosition: {
        top: number;
        left: number;
    };
    onDelete?: () => void;
    onCut?: () => void;
    onCopy?: () => void;
    onDuplicate?: () => void;
    anyConnectableNodeSelected: boolean;
    anyConnectionToSelectedNode: boolean;
    onBreakNodeLinks?: () => void;
}): JSX.Element;

declare function EdgeMenu({ open, onClose, anchorPosition, onDelete, }: {
    open: boolean;
    onClose: () => void;
    anchorPosition: {
        top: number;
        left: number;
    };
    onDelete?: () => void;
}): JSX.Element;

declare function HandleMenu({ open, onClose, anchorPosition, connection, onBreakLinks, }: {
    open: boolean;
    onClose: () => void;
    anchorPosition: {
        top: number;
        left: number;
    };
    connection: number | undefined;
    onBreakLinks: () => void;
}): JSX.Element;

declare const SearchMenu: React$1.NamedExoticComponent<{
    open: boolean;
    onClose: () => void;
    anchorPosition: {
        top: number;
        left: number;
    };
    addNode?: ((configType: string) => void) | undefined;
    clear?: (() => void) | undefined;
    moreCommands?: Command[] | undefined;
}>;

declare const ConnectionTip: React$1.NamedExoticComponent<{
    open: boolean;
    onClose: () => void;
    anchorPosition: {
        top: number;
        left: number;
    };
    connectionStatus?: ConnectionStatus | undefined;
}>;

declare function Progress({ enable }: {
    enable: boolean;
}): JSX.Element;

interface ITokens {
    authenticated: boolean;
    Authorization: null | string;
    'X-XSRFToken': null | string;
}
declare function NodeLibraryList({ title, nodeExtensions, onUninstall, onEnable, onDisable, url, tokens, }: {
    title: string;
    nodeExtensions: Record<string, NodePackage | NodeConfig>;
    onUninstall?: (pkg: string) => void;
    onEnable?: (pkg: string) => void;
    onDisable?: (pkg: string) => void;
    url?: string;
    tokens?: ITokens;
}): JSX.Element;

interface INodeLibraryItem {
    title: string;
    href?: string;
    description?: string;
    onUninstall?: () => void;
    onEnable?: () => void;
    onDisable?: () => void;
}
declare function NodeLibraryItem({ title, href, description, onUninstall, onEnable, onDisable, }: INodeLibraryItem): JSX.Element;

export { ClipboardInfo, Command, Comment, ConnectableData, ConnectionAction, ConnectionStatus, ConnectionTip, DataTypes, Edge, EdgeMenu, Graph, GraphEdgeConfig, GraphNodeConfig, GraphState, Handle as HandleData, HandleMenu, IMouseTracker, INodeLibraryItem, ISceneActions, ISceneState, InPlaceTextArea, InPlaceInput as InplaceInput, LoadDefaultModule, LoadPackageToRegistry, MousePos, Node, NodeConfig, NodeLibraryItem, NodeLibraryList, NodeMenu, NodePackage, ParseModule, Progress, SearchMenu, SerializedGraph, SerializedGraphEdge, SerializedGraphNode, SerializedHandle, StickyNote, VPEditor, VariableNodeData, WidgetFactory, addNewType, getMaxConnection, isCommentNode, isDataTypeMatch, INodeModule as libraryConfig, nodeConfigRegistry, selectedElementsCounts, useGraph, useGui, useKeyDown, useScene, useTrackMousePos, widgetFactory };
