/*!
 * Copyright (c) Microsoft. All rights reserved.
 * Licensed under the MIT license. See LICENSE file in the project.
 */ import { useEffect, useState } from 'react';
import { DisplayOrder } from '../enums.js';
/**
 * Gets the workflow processing steps
 * @param workflow - the workflow intsance
 * @returns
 */ export function useWorkflowSteps(workflow, order = DisplayOrder.LastOnTop) {
    const [steps, setSteps] = useState(orderSteps(workflow.steps, order));
    // listen for workflow changes and update the steps
    useEffect(()=>{
        workflow.onChange(()=>{
            setSteps(orderSteps(workflow.steps, order));
        });
    }, [
        workflow,
        order,
        setSteps
    ]);
    return steps;
}
function orderSteps(_steps, order) {
    const steps = [
        ..._steps
    ];
    return order === DisplayOrder.FirstOnTop ? steps : steps.reverse();
}
