import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import Xarrow from "@appglue/xarrow/lib";
import { ObserveState } from "../../CommonUI/StateManagement/ObserveState";
import { FlowConstants } from "../CommonUI/FlowConstants";
import { FlowStepOutputInstructionType } from "../Structure/FlowStepOutputInstructions";
export const ExtraConnection = (props) => {
    return (_jsx(ObserveState, { listenTo: props.connection.fromInstruction, properties: ["strategy"], control: () => {
            return (_jsx(Xarrow, { start: props.connection.fromId, end: props.connection.toId, startAnchor: [
                    {
                        position: "bottom",
                        offset: {
                            x: 5,
                        },
                    },
                ], endAnchor: "top", strokeWidth: 2, headSize: 3, color: props.connection.fromInstruction.strategy === FlowStepOutputInstructionType.END_FLOW
                    ? FlowConstants.END_LINE_COLOR
                    : FlowConstants.ERROR_LINE_COLOR, _debug: false, divContainerStyle: { zIndex: 3 }, path: props.editContext.displayBehavior.linePathType }, props.connection.fromId));
        } }, void 0));
};
export const FlowEditorExtraConnections = (props) => {
    const renderEndLines = () => (_jsx(ObserveState, { listenTo: props.flow.endSequence, properties: ["isCollapsed"], control: () => {
            return props.flow
                .getEndFlowConnections()
                .map((c) => (_jsx(ExtraConnection, { connection: c, editContext: props.editContext }, c.fromId)));
        } }, void 0));
    const renderErrorLines = () => (_jsx(ObserveState, { listenTo: props.flow.endSequence, properties: ["isCollapsed"], control: () => {
            return props.flow
                .getErrorFlowConnections()
                .map((c) => (_jsx(ExtraConnection, { connection: c, editContext: props.editContext }, c.fromId)));
        } }, void 0));
    return (_jsx(ObserveState, { listenTo: props.editContext, properties: ["showErrorOrEndConnections", "isShowErrorBranch", "viewMode"], control: () => (_jsxs(_Fragment, { children: [renderEndLines(), renderErrorLines()] }, void 0)) }, void 0));
};
//# sourceMappingURL=XFlowEditor.ExtraConnection.js.map