/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var vue = require('vue');
var isFunction = require('lodash/isFunction');
var iconsVueNext = require('@ldesign/icons-vue-next');
var hooks_useConfig = require('../hooks/useConfig.js');
var hooks_useGlobalIcon = require('../hooks/useGlobalIcon.js');
var steps_stepItemProps = require('./step-item-props.js');
var configProvider_useConfig = require('../config-provider/useConfig.js');
var hooks_tnode = require('../hooks/tnode.js');
require('lodash/cloneDeep');
require('lodash/isString');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-f4db2590.js');
require('dayjs');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var isFunction__default = /*#__PURE__*/_interopDefaultLegacy(isFunction);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _StepItem = vue.defineComponent({
  name: "TStepItem",
  props: _objectSpread(_objectSpread({}, steps_stepItemProps["default"]), {}, {
    index: Number
  }),
  setup: function setup(props2) {
    var stepsState = vue.inject("StepsState", void 0);
    var stepsProps = vue.inject("StepsProps", void 0);
    var _useConfig = configProvider_useConfig.useConfig("steps"),
      globalConfig = _useConfig.globalConfig;
    var _useGlobalIcon = hooks_useGlobalIcon.useGlobalIcon({
        CheckIcon: iconsVueNext.CheckIcon,
        CloseIcon: iconsVueNext.CloseIcon
      }),
      CheckIcon = _useGlobalIcon.CheckIcon,
      CloseIcon = _useGlobalIcon.CloseIcon;
    var canClick = vue.computed(function () {
      return props2.status !== "process" && !(stepsProps !== null && stepsProps !== void 0 && stepsProps.readonly);
    });
    var onStepClick = function onStepClick(e) {
      if (!canClick.value) return;
      var val = props2.value === void 0 ? props2.index : props2.value;
      stepsState.setCurrent(val, stepsState.current, {
        e: e
      });
    };
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("steps-item");
    var statusClass = vue.computed(function () {
      return _defineProperty__default["default"]({}, "".concat(COMPONENT_NAME.value, "--").concat(props2.status), props2.status);
    });
    var baseClass = vue.computed(function () {
      return [COMPONENT_NAME.value, statusClass.value];
    });
    var iconClass = vue.computed(function () {
      return ["".concat(COMPONENT_NAME.value, "__icon"), statusClass.value];
    });
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var renderContent = hooks_tnode.useContent();
    var renderIcon = function renderIcon() {
      var defaultIcon;
      if (stepsProps.theme === "default") {
        var icon = "";
        switch (props2.status) {
          case "finish":
            icon = vue.createVNode(CheckIcon, null, null);
            break;
          case "error":
            if (isFunction__default["default"](globalConfig.value.errorIcon)) icon = globalConfig.value.errorIcon(vue.h);else icon = vue.createVNode(CloseIcon, null, null);
            break;
          default:
            icon = String(props2.index + 1);
            break;
        }
        defaultIcon = vue.createVNode("span", {
          "class": "".concat(COMPONENT_NAME.value, "__icon--number")
        }, [icon]);
      }
      return renderTNodeJSX("icon", defaultIcon);
    };
    return function () {
      return vue.createVNode("div", {
        "class": baseClass.value
      }, [vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__inner ").concat(canClick.value ? "".concat(COMPONENT_NAME.value, "--clickable") : ""),
        "onClick": onStepClick
      }, [vue.createVNode("div", {
        "class": iconClass.value
      }, [renderIcon()]), vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__content")
      }, [vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__title")
      }, [renderTNodeJSX("title")]), vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__description")
      }, [renderContent("default", "content")]), vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__extra")
      }, [renderTNodeJSX("extra")])])])]);
    };
  }
});

exports["default"] = _StepItem;
//# sourceMappingURL=step-item.js.map
