import React from "react";
import { BreadcrumbShorter } from "../ui/BreadcrumbShorter/BreadcrumbShorter";
import { StyledLink } from "../Breadcrumbs.styles";
export const shortItems = (items, renderSeparator, showItems)=>{
    if (!showItems || showItems < 2 || items.length <= showItems) {
        return items;
    }
    const leftSlice = Math.floor(showItems / 2);
    const rightSlice = items.length - leftSlice - showItems % 2;
    const renderItems = items.slice(leftSlice, rightSlice);
    const shorter = /*#__PURE__*/ React.createElement(BreadcrumbShorter, {
        separator: renderSeparator
    }, renderItems);
    items.splice(leftSlice, rightSlice - leftSlice, shorter);
    return items;
};
export const getRenderItems = (items, renderSeparator, showItems)=>{
    const renderItems = shortItems(items.map((item)=>{
        if (item.renderItem) {
            return item.renderItem();
        }
        const { title, disabled, href, onClick } = item;
        return /*#__PURE__*/ React.createElement(StyledLink, {
            tabIndex: disabled ? -1 : 0,
            href: href,
            disabled: disabled,
            onClick: onClick,
            isHref: Boolean(href || onClick)
        }, title);
    }), renderSeparator, showItems);
    return renderItems;
};
