import { jsxDEV as _jsxDEV } from "react/jsx-dev-runtime";
import { getTranslation } from '@payloadcms/translations';
import React from 'react';
import { formatDate } from '../../../utilities/formatDocTitle/formatDateTitle.js';
import { Button } from '../../Button/index.js';
import { Pill } from '../../Pill/index.js';
export const buildUpcomingColumns = ({ dateFormat, deleteHandler, docs, i18n, localization, supportedTimezones, t })=>{
    const columns = [
        {
            accessor: 'input.type',
            active: true,
            field: {
                name: '',
                type: 'text'
            },
            Heading: /*#__PURE__*/ _jsxDEV("span", {
                children: t('version:type')
            }, void 0, false, {
                fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                lineNumber: 39,
                columnNumber: 16
            }, this),
            renderedCells: docs.map((doc)=>{
                const type = doc.input?.type;
                return /*#__PURE__*/ _jsxDEV(Pill, {
                    pillStyle: type === 'publish' ? 'success' : 'warning',
                    size: "small",
                    children: [
                        type === 'publish' && t('version:publish'),
                        type === 'unpublish' && t('version:unpublish')
                    ]
                }, doc.id, true, {
                    fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                    lineNumber: 44,
                    columnNumber: 11
                }, this);
            })
        },
        {
            accessor: 'waitUntil',
            active: true,
            field: {
                name: '',
                type: 'date'
            },
            Heading: /*#__PURE__*/ _jsxDEV("span", {
                children: t('general:time')
            }, void 0, false, {
                fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                lineNumber: 58,
                columnNumber: 16
            }, this),
            renderedCells: docs.map((doc)=>/*#__PURE__*/ _jsxDEV("span", {
                    children: formatDate({
                        date: doc.waitUntil,
                        i18n,
                        pattern: dateFormat,
                        timezone: doc.input.timezone
                    })
                }, doc.id, false, {
                    fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                    lineNumber: 60,
                    columnNumber: 9
                }, this))
        },
        {
            accessor: 'input.timezone',
            active: true,
            field: {
                name: '',
                type: 'text'
            },
            Heading: /*#__PURE__*/ _jsxDEV("span", {
                children: t('general:timezone')
            }, void 0, false, {
                fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                lineNumber: 77,
                columnNumber: 16
            }, this),
            renderedCells: docs.map((doc)=>{
                const matchedTimezone = supportedTimezones.find((timezone)=>timezone.value === doc.input.timezone);
                const timezone = matchedTimezone?.label || doc.input.timezone;
                return /*#__PURE__*/ _jsxDEV("span", {
                    children: timezone || t('general:noValue')
                }, doc.id, false, {
                    fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                    lineNumber: 85,
                    columnNumber: 16
                }, this);
            })
        }
    ];
    if (localization) {
        columns.push({
            accessor: 'input.locale',
            active: true,
            field: {
                name: '',
                type: 'text'
            },
            Heading: /*#__PURE__*/ _jsxDEV("span", {
                children: t('general:locale')
            }, void 0, false, {
                fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                lineNumber: 98,
                columnNumber: 16
            }, this),
            renderedCells: docs.map((doc)=>{
                if (doc.input.locale) {
                    const matchedLocale = localization.locales.find((locale)=>locale.code === doc.input.locale);
                    if (matchedLocale) {
                        return /*#__PURE__*/ _jsxDEV("span", {
                            children: getTranslation(matchedLocale.label, i18n)
                        }, doc.id, false, {
                            fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                            lineNumber: 105,
                            columnNumber: 20
                        }, this);
                    }
                }
                return /*#__PURE__*/ _jsxDEV("span", {
                    children: t('general:all')
                }, doc.id, false, {
                    fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                    lineNumber: 109,
                    columnNumber: 16
                }, this);
            })
        });
    }
    columns.push({
        accessor: 'delete',
        active: true,
        field: {
            name: 'delete',
            type: 'text'
        },
        Heading: /*#__PURE__*/ _jsxDEV("span", {
            children: t('general:delete')
        }, void 0, false, {
            fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
            lineNumber: 121,
            columnNumber: 14
        }, this),
        renderedCells: docs.map((doc)=>/*#__PURE__*/ _jsxDEV(Button, {
                buttonStyle: "icon-label",
                className: "schedule-publish__delete",
                icon: "x",
                onClick: (e)=>{
                    e.preventDefault();
                    deleteHandler(doc.id);
                },
                tooltip: t('general:delete')
            }, doc.id, false, {
                fileName: "src/elements/PublishButton/ScheduleDrawer/buildUpcomingColumns.tsx",
                lineNumber: 123,
                columnNumber: 7
            }, this))
    });
    return columns;
};

//# sourceMappingURL=buildUpcomingColumns.js.map