export var WAIT_NUM;
(function (WAIT_NUM) {
    WAIT_NUM[WAIT_NUM["WAIT_UNSPECIFIED"] = 0] = "WAIT_UNSPECIFIED";
    WAIT_NUM[WAIT_NUM["WAIT_ALL"] = 1] = "WAIT_ALL";
    WAIT_NUM[WAIT_NUM["WAIT_NONE"] = 2] = "WAIT_NONE";
})(WAIT_NUM || (WAIT_NUM = {}));
export var WAIT_STR;
(function (WAIT_STR) {
    WAIT_STR["WAIT_UNSPECIFIED"] = "WAIT_UNSPECIFIED";
    WAIT_STR["WAIT_ALL"] = "WAIT_ALL";
    WAIT_STR["WAIT_NONE"] = "WAIT_NONE";
})(WAIT_STR || (WAIT_STR = {}));
// loop
export var LOOP_TYPE;
(function (LOOP_TYPE) {
    LOOP_TYPE["UNSPECIFIED"] = "TYPE_UNSPECIFIED";
    LOOP_TYPE["FOR"] = "TYPE_FOR";
    LOOP_TYPE["FOREACH"] = "TYPE_FOREACH";
    LOOP_TYPE["WHILE"] = "TYPE_WHILE";
})(LOOP_TYPE || (LOOP_TYPE = {}));
// variables
export var VariableType;
(function (VariableType) {
    VariableType["UNSPECIFIED"] = "TYPE_UNSPECIFIED";
    VariableType["SIMPLE"] = "TYPE_SIMPLE";
    VariableType["ADVANCED"] = "TYPE_ADVANCED";
})(VariableType || (VariableType = {}));
export var VariableMode;
(function (VariableMode) {
    VariableMode["UNSPECIFIED"] = "MODE_UNSPECIFIED";
    VariableMode["READ"] = "MODE_READ";
    VariableMode["READWRITE"] = "MODE_READWRITE";
})(VariableMode || (VariableMode = {}));
const ALL_BLOCK_TYPES = [
    'break',
    'return',
    'wait',
    'throw',
    'parallel',
    'conditional',
    'loop',
    'tryCatch',
    'step',
    'variables',
    'send',
    'stream'
];
export const BlockType = {
    CONDITION: 'CONDITION',
    LOOP: 'LOOP',
    PARALLEL: 'PARALLEL',
    TRY_CATCH: 'TRY_CATCH',
    VARIABLES: 'VARIABLES',
    RETURN: 'RETURN',
    BREAK: 'BREAK',
    WAIT: 'WAIT',
    THROW: 'THROW',
    STEP: 'STEP',
    SEND: 'SEND',
    STREAM: 'STREAM'
};
function getBlockType(type) {
    switch (type) {
        case 'break':
            return BlockType.BREAK;
        case 'return':
            return BlockType.RETURN;
        case 'wait':
            return BlockType.WAIT;
        case 'throw':
            return BlockType.THROW;
        case 'parallel':
            return BlockType.PARALLEL;
        case 'conditional':
            return BlockType.CONDITION;
        case 'loop':
            return BlockType.LOOP;
        case 'tryCatch':
            return BlockType.TRY_CATCH;
        case 'variables':
            return BlockType.VARIABLES;
        case 'send':
            return BlockType.SEND;
        case 'stream':
            return BlockType.STREAM;
        case 'step':
            return BlockType.STEP;
        default: {
            const exhaustiveCheck = type;
            throw new Error(`Unhandled block type: ${exhaustiveCheck}`);
        }
    }
}
export function convertBlock(backendBlock) {
    for (const blockType of ALL_BLOCK_TYPES) {
        if (blockType in backendBlock) {
            const config = backendBlock[blockType];
            if (config != null) {
                return {
                    type: getBlockType(blockType),
                    config
                };
            }
        }
    }
    return null;
}
export function isStepBlock(block) {
    return block.type === BlockType.STEP;
}
export function isControlBlock(block) {
    return !isStepBlock(block);
}
export function getPluginType(block) {
    if (isStepBlock(block)) {
        return block.config.integration ?? null;
    }
    return null;
}
//# sourceMappingURL=control-flow.js.map