'use client';
import { FiCommand } from '@react-icons/all-files/fi/FiCommand';
// import { VscColorMode } from '@react-icons/all-files/vsc/VscColorMode';
import { VscGithubInverted } from '@react-icons/all-files/vsc/VscGithubInverted';
import { VscMenu } from '@react-icons/all-files/vsc/VscMenu';
import { VscSearch } from '@react-icons/all-files/vsc/VscSearch';
import { Button } from 'ariakit/button';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
// import { useTheme } from 'next-themes';
import { Fragment, useEffect, useMemo, useState } from 'react';
import { useCmdK } from '~/contexts/cmdK';
import { useNav } from '~/contexts/nav';
export function Header() {
const pathname = usePathname();
// eslint-disable-next-line @typescript-eslint/unbound-method
const { setOpened } = useNav();
// const { resolvedTheme, setTheme } = useTheme();
const dialog = useCmdK();
// const toggleTheme = () => setTheme(resolvedTheme === 'light' ? 'dark' : 'light');
const [asPathWithoutQueryAndAnchor, setAsPathWithoutQueryAndAnchor] = useState('');
useEffect(() => {
setAsPathWithoutQueryAndAnchor(pathname?.split('?')[0]?.split('#')[0] ?? '');
}, [pathname]);
const asPathWithoutContainerKey = useMemo(
() => asPathWithoutQueryAndAnchor?.split(':')[0] ?? '',
[asPathWithoutQueryAndAnchor],
);
const pathElements = useMemo(
() =>
asPathWithoutContainerKey
.split('/')
.slice(1)
.map((path, idx, original) => (
{path}
)),
[asPathWithoutContainerKey],
);
const breadcrumbs = useMemo(
() =>
pathElements.flatMap((el, idx, array) => {
if (idx === 0) {
return (
/
{el}
/
);
}
if (idx !== array.length - 1) {
return (
{el}
/
);
}
return {el};
}),
[pathElements],
);
return (
{breadcrumbs}
{/*
*/}
);
}