/**
 * 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 hooks_useConfig = require('../hooks/useConfig.js');
var hooks_tnode = require('../hooks/tnode.js');
var loading_index = require('../loading/index.js');
var timeline_hooks = require('./hooks.js');
var timeline_timeLineItemProps = require('./time-line-item-props.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
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');
require('../utils/withInstall.js');
require('../loading/directive.js');
require('../loading/plugin.js');
require('../utils/dom.js');
require('../utils/easing.js');
require('../loading/loading.js');
require('@babel/runtime/helpers/slicedToArray');
require('../hooks/useTeleport.js');
require('../loading/props.js');
require('../loading/icon/gradient.js');
require('../_common/js/loading/circle-adapter.js');
require('../_common/js/utils/set-style.js');
require('../_common/js/utils/helper.js');
require('@babel/runtime/helpers/toConsumableArray');
require('@babel/runtime/helpers/objectWithoutProperties');
require('lodash/isNull');
require('lodash/isUndefined');
require('lodash/isNumber');

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

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

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 DEFAULT_THEME = ["default", "primary", "success", "warning", "error"];
var _TimelineItem = vue.defineComponent({
  name: "TTimelineItem",
  props: _objectSpread(_objectSpread({}, timeline_timeLineItemProps["default"]), {}, {
    index: {
      type: Number
    }
  }),
  setup: function setup(props) {
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("timeline-item");
    var TimelineProvider = vue.inject(timeline_hooks.TimelineInjectKey, timeline_hooks.DEFAULT_PROVIDER);
    var renderContent = hooks_tnode.useContent();
    var renderTNodeJSX = hooks_tnode.useTNodeJSX();
    var getPositionClassName = function getPositionClassName(index) {
      var _props$labelAlign;
      var _TimelineProvider$val = TimelineProvider.value,
        layout = _TimelineProvider$val.layout,
        renderAlign = _TimelineProvider$val.renderAlign;
      var timelineItemAlign = (_props$labelAlign = props.labelAlign) !== null && _props$labelAlign !== void 0 ? _props$labelAlign : renderAlign;
      var left = layout === "horizontal" ? "top" : "left";
      var right = layout === "horizontal" ? "bottom" : "right";
      if (timelineItemAlign === "alternate") return index % 2 === 0 ? "".concat(COMPONENT_NAME.value, "-").concat(left) : "".concat(COMPONENT_NAME.value, "-").concat(right);
      if (timelineItemAlign === "left" || timelineItemAlign === "top") return "".concat(COMPONENT_NAME.value, "-").concat(left);
      if (timelineItemAlign === "right" || timelineItemAlign === "bottom") return "".concat(COMPONENT_NAME.value, "-").concat(right);
      return "";
    };
    return function () {
      var _ref, _ref2;
      var _TimelineProvider$val2 = TimelineProvider.value,
        mode = _TimelineProvider$val2.mode,
        theme = _TimelineProvider$val2.theme,
        itemsStatus = _TimelineProvider$val2.itemsStatus,
        reverse = _TimelineProvider$val2.reverse;
      var loading = props.loading,
        dotColor = props.dotColor,
        index = props.index;
      var labelNode = renderTNodeJSX("label");
      var dotElement = renderTNodeJSX("dot");
      var dotContentClass = "".concat(COMPONENT_NAME.value, "__dot-content");
      if (dotElement !== null && dotElement !== void 0 && dotElement.props) {
        var _dotElement$props;
        var classes = dotElement === null || dotElement === void 0 ? void 0 : (_dotElement$props = dotElement.props) === null || _dotElement$props === void 0 ? void 0 : _dotElement$props["class"];
        dotElement.props["class"] = classes ? [dotContentClass, classes].join(" ") : dotContentClass;
      }
      return vue.createVNode("li", {
        "class": ["".concat(COMPONENT_NAME.value), "".concat(getPositionClassName(props.index))]
      }, [mode === "alternate" && labelNode && vue.createVNode("div", {
        "class": ["".concat(COMPONENT_NAME.value, "__label"), "".concat(COMPONENT_NAME.value, "__label--").concat(mode)]
      }, [labelNode]), vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__wrapper")
      }, [vue.createVNode("div", {
        "class": (_ref = {}, _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "__dot"), true), _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "__dot--custom"), !!dotElement || !dotElement && loading), _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "__dot--").concat(dotColor), DEFAULT_THEME.includes(dotColor)), _ref),
        "style": {
          borderColor: !DEFAULT_THEME.includes(dotColor) && dotColor
        }
      }, [!dotElement && loading && vue.createVNode(loading_index.Loading, {
        "size": "12px",
        "class": dotContentClass
      }, null), dotElement]), vue.createVNode("div", {
        "class": (_ref2 = {}, _defineProperty__default["default"](_ref2, "".concat(COMPONENT_NAME.value, "__tail"), true), _defineProperty__default["default"](_ref2, "".concat(COMPONENT_NAME.value, "__tail--theme-").concat(theme), true), _defineProperty__default["default"](_ref2, "".concat(COMPONENT_NAME.value, "__tail--status-").concat(itemsStatus[index]), reverse), _ref2)
      }, null)]), vue.createVNode("div", {
        "class": "".concat(COMPONENT_NAME.value, "__content")
      }, [renderContent("default", "content"), mode === "same" && labelNode && vue.createVNode("div", {
        "class": ["".concat(COMPONENT_NAME.value, "__label"), "".concat(COMPONENT_NAME.value, "__label--").concat(mode)]
      }, [labelNode])])]);
    };
  }
});

exports["default"] = _TimelineItem;
//# sourceMappingURL=timeline-item.js.map
