import React, { Fragment } from 'react';
import { DocumentTabLink } from './TabLink.js';
export const baseClass = 'doc-tab';
export const DocumentTab = (props)=>{
    const { Pill, apiURL, collectionConfig, condition, config, globalConfig, href: tabHref, i18n, isActive: tabIsActive, label, newTab } = props;
    const { routes } = config;
    let href = typeof tabHref === 'string' ? tabHref : '';
    let isActive = typeof tabIsActive === 'boolean' ? tabIsActive : false;
    if (typeof tabHref === 'function') {
        href = tabHref({
            apiURL,
            collection: collectionConfig,
            global: globalConfig,
            routes
        });
    }
    if (typeof tabIsActive === 'function') {
        isActive = tabIsActive({
            href
        });
    }
    const meetsCondition = !condition || condition && Boolean(condition({
        collectionConfig,
        config,
        globalConfig
    }));
    if (meetsCondition) {
        const labelToRender = typeof label === 'function' ? label({
            t: i18n.t
        }) : label;
        return /*#__PURE__*/ React.createElement(DocumentTabLink, {
            adminRoute: routes.admin,
            baseClass: baseClass,
            href: href,
            isActive: isActive,
            isCollection: !!collectionConfig && !globalConfig,
            newTab: newTab
        }, /*#__PURE__*/ React.createElement("span", {
            className: `${baseClass}__label`
        }, labelToRender, Pill && /*#__PURE__*/ React.createElement(Fragment, null, " ", /*#__PURE__*/ React.createElement(Pill, null))));
    }
    return null;
};

//# sourceMappingURL=index.js.map