import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator } from "@/components/ui/breadcrumb"
import { Button } from "@/components/ui/button"
import { Separator } from "@/components/ui/separator"
import { SidebarTrigger } from "@/components/ui/sidebar"
import { SlashIcon } from "lucide-react"
import Link from "next/link"
import React from "react"

interface SiteHeaderProps {
    breadcrumbs: {
        label: string
        href: string
    }[]
}

export function SiteHeader({ breadcrumbs }: SiteHeaderProps) {
    return (
        <header className="flex h-(--header-height) shrink-0 items-center gap-2 border-b transition-[width,height] ease-linear group-has-data-[collapsible=icon]/sidebar-wrapper:h-(--header-height)">
            <div className="flex w-full items-center gap-1 px-4 lg:gap-2 lg:px-6">
                <SidebarTrigger className="-ml-1" />
                <Separator
                    orientation="vertical"
                    className="mx-2 data-[orientation=vertical]:h-4"
                />
                <h1 className="text-base font-medium">
                    <Breadcrumb>
                        <BreadcrumbList>

                            {
                                breadcrumbs.map((breadcrumb, index) => (
                                    <React.Fragment key={breadcrumb.href}>
                                        <BreadcrumbItem key={breadcrumb.href}>
                                            <BreadcrumbLink asChild>
                                                <Link href={breadcrumb.href}>{breadcrumb.label}</Link>
                                            </BreadcrumbLink>
                                        </BreadcrumbItem>
                                        {index < breadcrumbs.length - 1 && (
                                            <BreadcrumbSeparator>
                                                <SlashIcon />
                                            </BreadcrumbSeparator>
                                        )}
                                    </React.Fragment>
                                ))
                            }
                        </BreadcrumbList>
                    </Breadcrumb>
                </h1>
            </div>
        </header>
    )
}
