import { jsx, jsxs } from "react/jsx-runtime";
import styled from "@emotion/styled";
import { Spacing } from "@uipath/apollo-core";
import { memo } from "react";
import { CanvasTooltip } from "../../components/CanvasTooltip.js";
import { Row } from "../../layouts/index.js";
const OlStyled = styled.ol`
  display: flex;
  flex-direction: row;
  margin: 0;
  padding: 0;
`;
const LiStyled = styled.li`
  display: flex;
  align-items: center;
  padding: 0;
`;
const Breadcrumb = /*#__PURE__*/ memo(({ items, delimiter = '>' })=>{
    const delimiterNode = 'string' == typeof delimiter ? /*#__PURE__*/ jsx("span", {
        "aria-hidden": "true",
        children: delimiter
    }) : delimiter;
    return /*#__PURE__*/ jsx(Row, {
        align: "center",
        style: {
            overflow: 'hidden',
            whiteSpace: 'nowrap',
            color: 'var(--color-foreground-de-emp)'
        },
        gap: Spacing.SpacingMicro,
        children: /*#__PURE__*/ jsx(OlStyled, {
            children: items.map((item, index)=>/*#__PURE__*/ jsxs(LiStyled, {
                    children: [
                        item.onClick ? /*#__PURE__*/ jsx("button", {
                            type: "button",
                            style: {
                                cursor: 'pointer',
                                background: 'none',
                                border: 'none',
                                padding: 0,
                                margin: 0,
                                color: 'inherit'
                            },
                            onClick: (e)=>item.onClick?.(e),
                            onKeyDown: (e)=>'Enter' === e.key && item.onClick?.(e),
                            children: /*#__PURE__*/ jsxs(Row, {
                                overflow: "hidden",
                                align: "center",
                                gap: Spacing.SpacingMicro,
                                "aria-current": index === items.length - 1 ? 'page' : void 0,
                                children: [
                                    item.startAdornment,
                                    /*#__PURE__*/ jsx(CanvasTooltip, {
                                        smartTooltip: true,
                                        content: item.label,
                                        children: /*#__PURE__*/ jsx("span", {
                                            className: `${index === items.length - 1 ? 'text-sm font-bold' : 'text-sm'} truncate`,
                                            "data-testid": `breadcrumb-item-${item.label}`,
                                            children: item.label
                                        })
                                    }),
                                    item.endAdornment
                                ]
                            })
                        }) : /*#__PURE__*/ jsxs(Row, {
                            overflow: "hidden",
                            align: "center",
                            gap: Spacing.SpacingMicro,
                            "aria-current": index === items.length - 1 ? 'page' : void 0,
                            children: [
                                item.startAdornment,
                                /*#__PURE__*/ jsx(CanvasTooltip, {
                                    smartTooltip: true,
                                    content: item.label,
                                    children: /*#__PURE__*/ jsx("span", {
                                        className: `${index === items.length - 1 ? 'text-sm font-bold' : 'text-sm'} truncate`,
                                        "data-testid": `breadcrumb-item-${item.label}`,
                                        children: item.label
                                    })
                                }),
                                item.endAdornment
                            ]
                        }),
                        index < items.length - 1 && delimiterNode
                    ]
                }, `${item.label}-${index}`))
        })
    });
});
Breadcrumb.displayName = 'Breadcrumb';
export { Breadcrumb };
