/**
 * amis-ui v6.14.0-beta.1
 * Copyright 2018-2025 fex
 */

'use strict';

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

var tslib = require('tslib');
require('react');
var amisCore = require('amis-core');
var TimelineItem = require('./TimelineItem.js');

var __react_jsx__ = require('react');
var _J$X_ = (__react_jsx__["default"] || __react_jsx__).createElement;
(__react_jsx__["default"] || __react_jsx__).Fragment;
exports.DirectionMode = void 0;
(function (DirectionMode) {
    DirectionMode["left"] = "left";
    DirectionMode["right"] = "right";
    DirectionMode["top"] = "top";
    DirectionMode["bottom"] = "bottom";
    DirectionMode["alternate"] = "alternate";
})(exports.DirectionMode || (exports.DirectionMode = {}));
function Timeline(props) {
    var items = props.items, style = props.style, cx = props.classnames, className = props.className, iconClassName = props.iconClassName, timeClassName = props.timeClassName, titleClassName = props.titleClassName, detailClassName = props.detailClassName, _a = props.direction, direction = _a === void 0 ? 'vertical' : _a, _b = props.reverse, reverse = _b === void 0 ? false : _b;
    var _c = props.mode, mode = _c === void 0 ? exports.DirectionMode.right : _c;
    var timelineDatasource = items === null || items === void 0 ? void 0 : items.slice();
    reverse && (timelineDatasource === null || timelineDatasource === void 0 ? void 0 : timelineDatasource.reverse());
    // 分成水平和垂直两种模式渲染
    if (direction === 'horizontal') {
        if ([exports.DirectionMode.right, exports.DirectionMode.left].includes(mode)) {
            mode = exports.DirectionMode.top;
        }
        // alternate模式下，交替生成时间和内容
        var isReverseScenario_1 = function (index, isAlternate) {
            return isAlternate ? index % 2 === 0 : false;
        };
        return (_J$X_("div", { className: cx('Timeline', "Timeline-".concat(direction), "Timeline-".concat(mode), className), style: style },
            _J$X_("div", { className: cx('Timeline-first-line') }, timelineDatasource === null || timelineDatasource === void 0 ? void 0 : timelineDatasource.map(function (item, index) {
                var _a;
                // 内容区偏移
                var align = TimelineItem.getAlignByDirection(direction, item.align);
                return (_J$X_("div", { className: cx('TimelineItem-content', (_a = {},
                        _a["TimelineItem-content-align--".concat(align)] = !!align,
                        _a)) }, isReverseScenario_1(index, mode === exports.DirectionMode.alternate) ||
                    mode === exports.DirectionMode.top ? (_J$X_(TimelineItem.TimelineTimeComponent, tslib.__assign({ key: "TimelineItem-".concat(index) }, item))) : (_J$X_("div", { className: cx('Timeline-inner-content-wrapper') },
                    _J$X_(TimelineItem.TimelineContentComponent, tslib.__assign({ key: "TimelineItem-".concat(index) }, item))))));
            })),
            _J$X_("div", { className: cx('Timeline-line') }, timelineDatasource === null || timelineDatasource === void 0 ? void 0 : timelineDatasource.map(function (item, index) { return (_J$X_(TimelineItem.TimelineLineComponent, tslib.__assign({ key: "TimelineItem-".concat(index) }, item, { direction: direction }))); })),
            _J$X_("div", { className: cx('Timeline-second-line') }, timelineDatasource === null || timelineDatasource === void 0 ? void 0 : timelineDatasource.map(function (item, index) {
                var _a;
                // 内容区偏移
                var align = TimelineItem.getAlignByDirection(direction, item.align);
                return (_J$X_("div", { className: cx('TimelineItem-content', (_a = {},
                        _a["TimelineItem-content-align--".concat(align)] = !!align,
                        _a)) }, isReverseScenario_1(index, mode === exports.DirectionMode.alternate) ||
                    mode === exports.DirectionMode.top ? (_J$X_("div", { className: cx('Timeline-inner-content-wrapper') },
                    _J$X_(TimelineItem.TimelineContentComponent, tslib.__assign({ key: "TimelineItem-".concat(index) }, item)))) : (_J$X_(TimelineItem.TimelineTimeComponent, tslib.__assign({ key: "TimelineItem-".concat(index) }, item)))));
            }))));
    }
    return (_J$X_("div", { className: cx('Timeline', "Timeline-".concat(direction), "Timeline-".concat(mode), className), style: style }, timelineDatasource === null || timelineDatasource === void 0 ? void 0 : timelineDatasource.map(function (item, index) { return (_J$X_(TimelineItem["default"], tslib.__assign({}, item, { key: "TimelineItem-".concat(index), iconClassName: item.iconClassName || iconClassName, timeClassName: item.timeClassName || timeClassName, titleClassName: item.titleClassName || titleClassName, detailClassName: item.detailClassName || detailClassName, direction: direction }))); })));
}
var Timeline$1 = amisCore.themeable(Timeline);

exports.Timeline = Timeline;
exports["default"] = Timeline$1;
