import { useMemo } from "react";
import { useEdgeExecutionState, useElementValidationStatus } from "../../../../hooks/index.js";
import { ElementStatusValues } from "../../../../types/execution.js";
import { edgeTargetStatusToEdgeColor, getStatusAnimation } from "../../EdgeUtils.js";
function resolveStatus(executionState, validation) {
    if (executionState) return executionState?.status ?? executionState;
    return validation?.validationStatus;
}
function useExecutionEdge(args) {
    const { edgeId, target, edgePath, enabled } = args;
    const executionState = useEdgeExecutionState(edgeId, target);
    const validation = useElementValidationStatus(edgeId);
    const status = enabled ? resolveStatus(executionState, validation) : void 0;
    const statusColor = status ? edgeTargetStatusToEdgeColor[status] : void 0;
    const animationPath = status === ElementStatusValues.InProgress ? edgePath : void 0;
    const animation = useMemo(()=>{
        if (null == animationPath) return null;
        return getStatusAnimation(status, animationPath);
    }, [
        status,
        animationPath
    ]);
    return {
        statusColor,
        animation
    };
}
export { useExecutionEdge };
