"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importStar(require("react"));
const react_router_dom_1 = require("react-router-dom");
const icons_1 = require("@ant-design/icons");
const antd_1 = require("antd");
const index_1 = require("@/components/index");
const system_1 = require("@/pages/system");
const period_format_1 = require("@/utils/period-format");
const ContentList = (props) => {
    const { applicationId, folderId, loading, contents } = props;
    const { pathname, search } = (0, react_router_dom_1.useLocation)();
    // i18n
    const { locale } = (0, react_1.useContext)(system_1.GlobalContext);
    const { content, global, version } = locale.business;
    const columns = [
        {
            title: global.nameLabel,
            dataIndex: 'title',
            render: (text, record) => {
                var _a;
                return (react_1.default.createElement(react_1.default.Fragment, null,
                    react_1.default.createElement(react_router_dom_1.Link, { to: {
                            pathname: '/builder',
                            search: `?applicationId=${applicationId}&folderId=${folderId}&fileId=${record.fileId}&contentId=${record.id}`,
                            state: { backPathname: pathname, backSearch: search },
                        } }, text),
                    record.urls && !record.isBase && record.urls.length > 0 && (react_1.default.createElement(antd_1.Popover, { placement: "bottom", content: react_1.default.createElement(react_1.default.Fragment, null, (_a = record.urls) === null || _a === void 0 ? void 0 : _a.map((url) => {
                            return (react_1.default.createElement("p", { key: url },
                                react_1.default.createElement("a", { href: url, target: "_blank" }, url)));
                        })), trigger: "hover" },
                        react_1.default.createElement(icons_1.LinkOutlined, { style: { marginLeft: 6 } })))));
            },
        },
        {
            title: global.type,
            dataIndex: 'version',
            key: 'version',
            render: (_text) => {
                return react_1.default.createElement(antd_1.Tag, { color: "orange" }, content.name);
            },
        },
        {
            title: version.liveVersion,
            dataIndex: 'version',
            key: 'version',
            render: (text) => {
                return text || '--';
            },
        },
        {
            title: global.locale,
            dataIndex: 'tag',
            key: 'tag',
            render: (_text, record) => {
                const localesTag = record.tags ? record.tags.filter((item) => item.locale) : [];
                return react_1.default.createElement(index_1.LocaleView, { locales: localesTag.map((item) => item.locale) });
            },
        },
        {
            title: global.creator,
            dataIndex: 'creator',
            key: 'creator',
            render: (_text, record) => {
                return record.creator ? record.creator.account : '--';
            },
        },
        {
            title: global.createTime,
            dataIndex: 'createTime',
            key: 'createTime',
            width: 200,
            render: (text) => (0, period_format_1.periodFormat)(text, 'unknown'),
        },
    ];
    return react_1.default.createElement(antd_1.Table, { rowKey: "id", loading: loading, pagination: false, columns: columns, dataSource: contents });
};
exports.default = ContentList;
