import React from 'react';
import type { SxProps, Theme } from '@mui/material';
import { BaseBreadcrumbs, type BreadcrumbItem } from '@/components/Breadcrumbs';

interface KnowledgeBreadcrumbsProps {
  sx?: SxProps<Theme>;
  /** 知识库相关的面包屑项目，可以完全自定义 */
  kbItems?: BreadcrumbItem[];
  /** 额外的面包屑项目，会添加到kbItems之后 */
  extraItems?: BreadcrumbItem[];
}

const KnowledgeBreadcrumbs: React.FC<KnowledgeBreadcrumbsProps> = ({ 
  sx,
  kbItems = [],
  extraItems = []
}) => {
  // 合并所有面包屑项目
  const allItems = [...kbItems, ...extraItems];
  
  // 确保最后一个项目被标记为最后一项
  const breadcrumbItems = allItems.map((item, index) => ({
    ...item,
    isLast: index === allItems.length - 1
  }));

  return (
    <BaseBreadcrumbs 
      items={breadcrumbItems}
      sx={sx}
      linkVariant="body1"
    />
  );
};

export default KnowledgeBreadcrumbs;