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

import _defineProperty from '@babel/runtime/helpers/defineProperty';
import { defineComponent, computed, provide, createVNode, mergeProps } from 'vue';
import { usePrefixClass } from '../hooks/useConfig.js';
import { useChildComponentSlots } from '../hooks/slot.js';
import log from '../_common/js/log/log.js';
import TimeLineProps from './props.js';
import { TimelineInjectKey, DefaultAlign } from './hooks.js';
import _TimelineItem from './timeline-item.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import 'lodash/isString';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-c9c789a8.js';
import 'dayjs';
import '../hooks/tnode.js';
import 'lodash/camelCase';
import 'lodash/kebabCase';
import '../utils/render-tnode.js';
import 'lodash/isEmpty';
import 'lodash/isObject';
import '../loading/index.js';
import '../utils/withInstall.js';
import '../loading/directive.js';
import '../loading/plugin.js';
import '../utils/dom.js';
import '../utils/easing.js';
import '../loading/loading.js';
import '@babel/runtime/helpers/slicedToArray';
import '../hooks/useTeleport.js';
import '../loading/props.js';
import '../loading/icon/gradient.js';
import '../_common/js/loading/circle-adapter.js';
import '../_common/js/utils/set-style.js';
import '../_common/js/utils/helper.js';
import '@babel/runtime/helpers/toConsumableArray';
import '@babel/runtime/helpers/objectWithoutProperties';
import 'lodash/isNull';
import 'lodash/isUndefined';
import 'lodash/isNumber';
import './time-line-item-props.js';

var _Timeline = defineComponent({
  name: "TTimeline",
  props: TimeLineProps,
  setup: function setup(props) {
    var COMPONENT_NAME = usePrefixClass("timeline");
    var renderAlign = computed(function () {
      var labelAlign = props.labelAlign,
        layout = props.layout;
      var res = layout === "vertical" ? "left" : "top";
      if (layout === "vertical" && labelAlign) {
        var index = DefaultAlign.horizontal.indexOf(labelAlign);
        var isError = index !== -1;
        isError && log.warn("Timeline", 'If layout is vertical, align should be "left","alternate" or "right" ');
        res = isError ? DefaultAlign.vertical[index] : labelAlign;
      }
      if (layout === "horizontal" && labelAlign) {
        var _index = DefaultAlign.vertical.indexOf(labelAlign);
        var _isError = _index !== -1;
        _isError && log.warn("Timeline", 'If layout is horizontal, align should be "top","alternate" or "bottom" ');
        res = _isError ? DefaultAlign.horizontal[_index] : labelAlign;
      }
      return res;
    });
    var getChildComponentSlots = useChildComponentSlots();
    var timelineItems = computed(function () {
      var items = getChildComponentSlots("TTimelineItem");
      if (props.reverse) items.reverse();
      return items;
    });
    var TimeLineProvide = 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;
    provide(TimelineInjectKey, TimeLineProvide);
    return function () {
      var _ref;
      return createVNode("ul", {
        "class": ["".concat(COMPONENT_NAME.value), (_ref = {}, _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "-").concat(renderAlign.value), true), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "-reverse"), props.reverse), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "-").concat(props.layout), true), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "-label"), hasLabelItem), _defineProperty(_ref, "".concat(COMPONENT_NAME.value, "-label--").concat(props.mode), true), _ref)]
      }, [timelineItems.value.map(function (item, index) {
        return createVNode(_TimelineItem, mergeProps(item.props, {
          "index": index,
          "class": _defineProperty({}, "".concat(COMPONENT_NAME.value, "-item--last"), index === timelineItems.value.length - 1)
        }), item.children);
      })]);
    };
  }
});

export { _Timeline as default };
//# sourceMappingURL=timeline.js.map
