/**
 * 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_slot = require('../hooks/slot.js');
var _common_js_log_log = require('../_common/js/log/log.js');
var timeline_props = require('./props.js');
var timeline_hooks = require('./hooks.js');
var timeline_timelineItem = require('./timeline-item.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('../hooks/tnode.js');
require('lodash/camelCase');
require('lodash/kebabCase');
require('../utils/render-tnode.js');
require('lodash/isEmpty');
require('lodash/isObject');
require('../loading/index.js');
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');
require('./time-line-item-props.js');

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

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

var _Timeline = vue.defineComponent({
  name: "TTimeline",
  props: timeline_props["default"],
  setup: function setup(props) {
    var COMPONENT_NAME = hooks_useConfig.usePrefixClass("timeline");
    var renderAlign = vue.computed(function () {
      var labelAlign = props.labelAlign,
        layout = props.layout;
      var res = layout === "vertical" ? "left" : "top";
      if (layout === "vertical" && labelAlign) {
        var index = timeline_hooks.DefaultAlign.horizontal.indexOf(labelAlign);
        var isError = index !== -1;
        isError && _common_js_log_log["default"].warn("Timeline", 'If layout is vertical, align should be "left","alternate" or "right" ');
        res = isError ? timeline_hooks.DefaultAlign.vertical[index] : labelAlign;
      }
      if (layout === "horizontal" && labelAlign) {
        var _index = timeline_hooks.DefaultAlign.vertical.indexOf(labelAlign);
        var _isError = _index !== -1;
        _isError && _common_js_log_log["default"].warn("Timeline", 'If layout is horizontal, align should be "top","alternate" or "bottom" ');
        res = _isError ? timeline_hooks.DefaultAlign.horizontal[_index] : labelAlign;
      }
      return res;
    });
    var getChildComponentSlots = hooks_slot.useChildComponentSlots();
    var timelineItems = vue.computed(function () {
      var items = getChildComponentSlots("TTimelineItem");
      if (props.reverse) items.reverse();
      return items;
    });
    var TimeLineProvide = vue.computed(function () {
      var theme = props.theme,
        reverse = props.reverse,
        layout = props.layout,
        labelAlign = props.labelAlign,
        mode = props.mode;
      return {
        theme: theme,
        reverse: reverse,
        itemsStatus: [""],
        layout: layout,
        globalAlign: labelAlign,
        mode: mode,
        renderAlign: renderAlign.value
      };
    });
    var hasLabelItem = 1;
    vue.provide(timeline_hooks.TimelineInjectKey, TimeLineProvide);
    return function () {
      var _ref;
      return vue.createVNode("ul", {
        "class": ["".concat(COMPONENT_NAME.value), (_ref = {}, _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "-").concat(renderAlign.value), true), _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "-reverse"), props.reverse), _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "-").concat(props.layout), true), _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "-label"), hasLabelItem), _defineProperty__default["default"](_ref, "".concat(COMPONENT_NAME.value, "-label--").concat(props.mode), true), _ref)]
      }, [timelineItems.value.map(function (item, index) {
        return vue.createVNode(timeline_timelineItem["default"], vue.mergeProps(item.props, {
          "index": index,
          "class": _defineProperty__default["default"]({}, "".concat(COMPONENT_NAME.value, "-item--last"), index === timelineItems.value.length - 1)
        }), item.children);
      })]);
    };
  }
});

exports["default"] = _Timeline;
//# sourceMappingURL=timeline.js.map
