"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    ExecutionStartPointIndicator: ()=>ExecutionStartPointIndicator,
    BreakpointIndicator: ()=>BreakpointIndicator,
    ValidationErrorIndicator: ()=>ValidationErrorIndicator,
    resolveAdornments: ()=>resolveAdornments,
    ExecutionStatusIndicator: ()=>ExecutionStatusIndicator,
    ValidationWarningIndicator: ()=>ValidationWarningIndicator
});
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
const external_index_cjs_namespaceObject = require("../index.cjs");
const external_react_namespaceObject = require("react");
const CanvasTooltip_cjs_namespaceObject = require("../components/CanvasTooltip.cjs");
const ExecutionStatusIcon_cjs_namespaceObject = require("../components/ExecutionStatusIcon/ExecutionStatusIcon.cjs");
const validation_cjs_namespaceObject = require("../types/validation.cjs");
function BreakpointIndicator({ isActive = true }) {
    if (!isActive) return null;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        className: "w-4 h-4 rounded-full bg-red-500 border border-red-600 shadow-sm",
        title: "Breakpoint"
    });
}
function ExecutionStartPointIndicator({ isActive = true }) {
    if (!isActive) return null;
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
        className: "w-4 h-4 rounded-full bg-blue-500 border border-blue-600 shadow-sm",
        title: "Execution Start Point"
    });
}
function ExecutionStatusIndicatorInternal({ status, count }) {
    const isExecutedMultipleTimes = void 0 !== count && count > 1;
    const color = (0, ExecutionStatusIcon_cjs_namespaceObject.getExecutionStatusColor)(status);
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
        children: [
            isExecutedMultipleTimes && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
                className: "text-sm pr-[2px]",
                style: {
                    color
                },
                children: count
            }),
            /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.ExecutionStatusIcon, {
                status: status
            })
        ]
    });
}
function SquareDashedIndicator() {
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
        content: "Node output is mocked",
        placement: "bottom",
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
            style: {
                display: 'inline-flex'
            },
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                icon: "square-dashed",
                size: 16,
                color: "var(--color-foreground-emp)"
            })
        })
    });
}
const ExecutionStatusIndicator = /*#__PURE__*/ (0, external_react_namespaceObject.memo)(ExecutionStatusIndicatorInternal);
function ValidationErrorIndicator({ message }) {
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
        content: message || 'Validation error',
        placement: "bottom",
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
            style: {
                display: 'inline-flex'
            },
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                icon: "circle-alert",
                size: 16,
                color: "var(--canvas-error-icon)"
            })
        })
    });
}
function ValidationWarningIndicator({ message }) {
    return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(CanvasTooltip_cjs_namespaceObject.CanvasTooltip, {
        content: message || 'Validation warning',
        placement: "bottom",
        children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("span", {
            style: {
                display: 'inline-flex'
            },
            children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_index_cjs_namespaceObject.CanvasIcon, {
                icon: "triangle-alert",
                size: 16,
                color: "var(--canvas-warning-icon)"
            })
        })
    });
}
const getDefaultAdornments = (context)=>{
    const executionState = context.executionState;
    const status = 'object' == typeof executionState ? executionState?.status : executionState;
    const count = 'object' == typeof executionState ? executionState.count : void 0;
    const hasBreakpoint = 'object' == typeof executionState && executionState?.debug;
    const isExecutionStartPoint = 'object' == typeof executionState && executionState?.isExecutionStartPoint;
    const isOutputPinned = 'object' == typeof executionState && executionState?.isOutputPinned;
    const hasValidationError = context.validationState?.validationStatus === validation_cjs_namespaceObject.ValidationErrorSeverity.ERROR || context.validationState?.validationStatus === validation_cjs_namespaceObject.ValidationErrorSeverity.CRITICAL;
    const hasValidationWarning = context.validationState?.validationStatus === validation_cjs_namespaceObject.ValidationErrorSeverity.WARNING;
    const getTopRight = ()=>{
        if (status && 'None' !== status) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ExecutionStatusIndicator, {
            status: status,
            count: count
        });
        if (hasValidationError) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ValidationErrorIndicator, {
            message: context.validationState?.validationError?.message
        });
        if (hasValidationWarning) return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ValidationWarningIndicator, {
            message: context.validationState?.validationError?.message
        });
        return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ExecutionStatusIndicator, {
            status: status,
            count: count
        });
    };
    return {
        topLeft: hasBreakpoint ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(BreakpointIndicator, {}) : void 0,
        topRight: getTopRight(),
        bottomLeft: isExecutionStartPoint ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(ExecutionStartPointIndicator, {}) : void 0,
        bottomRight: isOutputPinned ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(SquareDashedIndicator, {}) : void 0
    };
};
function resolveAdornments(context) {
    return getDefaultAdornments(context);
}
exports.BreakpointIndicator = __webpack_exports__.BreakpointIndicator;
exports.ExecutionStartPointIndicator = __webpack_exports__.ExecutionStartPointIndicator;
exports.ExecutionStatusIndicator = __webpack_exports__.ExecutionStatusIndicator;
exports.ValidationErrorIndicator = __webpack_exports__.ValidationErrorIndicator;
exports.ValidationWarningIndicator = __webpack_exports__.ValidationWarningIndicator;
exports.resolveAdornments = __webpack_exports__.resolveAdornments;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "BreakpointIndicator",
    "ExecutionStartPointIndicator",
    "ExecutionStatusIndicator",
    "ValidationErrorIndicator",
    "ValidationWarningIndicator",
    "resolveAdornments"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
