"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "Step", {
    enumerable: true,
    get: function() {
        return Step;
    }
});
var _interop_require_default = require("@swc/helpers/_/_interop_require_default");
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
var _define_property = require("@swc/helpers/_/_define_property");
var _object_spread = require("@swc/helpers/_/_object_spread");
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
var _classnames = /*#__PURE__*/ _interop_require_default._(require("classnames"));
var _context = require("../steps/context");
var _typings = require("../../utils/typings");
var defaultProps = (0, _object_spread_props._)((0, _object_spread._)({}, _typings.ComponentDefaults), {
    title: '',
    description: '',
    value: 0,
    icon: null
});
var Step = function Step(props) {
    var _ref = (0, _object_spread._)({}, defaultProps, props), children = _ref.children, title = _ref.title, description = _ref.description, value = _ref.value, icon = _ref.icon, className = _ref.className, restProps = (0, _object_without_properties._)(_ref, [
        "children",
        "title",
        "description",
        "value",
        "icon",
        "className"
    ]);
    var parent = (0, _react.useContext)(_context.DataContext);
    var dot = parent.propSteps.dot;
    var getCurrentStatus = function getCurrentStatus() {
        var index = value;
        if (index < +parent.propSteps.value) return 'finish';
        return index === +parent.propSteps.value ? 'process' : 'wait';
    };
    var handleClickStep = function handleClickStep() {
        var _parent_propSteps, _parent_propSteps1;
        ((_parent_propSteps = parent.propSteps) === null || _parent_propSteps === void 0 ? void 0 : _parent_propSteps.onStepClick) && ((_parent_propSteps1 = parent.propSteps) === null || _parent_propSteps1 === void 0 ? void 0 : _parent_propSteps1.onStepClick(value));
    };
    var classPrefix = "nut-step";
    var classes = (0, _classnames.default)(classPrefix, (0, _define_property._)({}, "".concat(classPrefix, "-").concat(getCurrentStatus()), true), className);
    var renderIconClass = function renderIconClass() {
        if (icon) {
            return "".concat(classPrefix, "-icon is-icon");
        }
        if (!dot && !icon) {
            return "".concat(classPrefix, "-icon is-text");
        }
        return "".concat(classPrefix, "-icon");
    };
    return /*#__PURE__*/ _react.default.createElement("div", (0, _object_spread_props._)((0, _object_spread._)({
        className: classes
    }, restProps), {
        onClick: handleClickStep
    }), /*#__PURE__*/ _react.default.createElement("div", {
        className: "nut-step-head"
    }, /*#__PURE__*/ _react.default.createElement("div", {
        className: "nut-step-line"
    }), /*#__PURE__*/ _react.default.createElement("div", {
        className: renderIconClass()
    }, icon || !dot && /*#__PURE__*/ _react.default.createElement("span", {
        className: "nut-step-inner"
    }, value))), (title || description) && /*#__PURE__*/ _react.default.createElement("div", {
        className: "nut-step-main"
    }, /*#__PURE__*/ _react.default.createElement("span", {
        className: "nut-step-title"
    }, title), description && /*#__PURE__*/ _react.default.createElement("span", {
        className: "nut-step-description"
    }, description)));
};
Step.displayName = 'NutStep';
