import type { OutlineIconName } from '$lib/components/ui/OutlineIcon.svelte';

export interface MemberNavItem {
	label: string;
	icon: OutlineIconName;
	href: string;
	stokOnly?: boolean;
}

export const MEMBER_NAV_ITEMS: MemberNavItem[] = [
	{ label: 'Dashboard', icon: 'home', href: '/dashboard' },
	{ label: 'Transaksi', icon: 'transaksi', href: '/transaksi' },
	{ label: 'Stok Barang', icon: 'stok', href: '/stok', stokOnly: true },
	{ label: 'Laporan', icon: 'laporan', href: '/laporan' },
	{ label: 'Langganan', icon: 'paket', href: '/langganan' },
	{ label: 'Panduan', icon: 'panduan', href: '/bantuan' },
	{ label: 'Profil', icon: 'user', href: '/profil' }
];

export const MEMBER_BOTTOM_NAV_ITEMS: MemberNavItem[] = [
	{ label: 'Beranda', icon: 'home', href: '/dashboard' },
	{ label: 'Transaksi', icon: 'transaksi', href: '/transaksi' },
	{ label: 'Stok', icon: 'stok', href: '/stok', stokOnly: true },
	{ label: 'Laporan', icon: 'laporan', href: '/laporan' },
	{ label: 'Paket', icon: 'paket', href: '/langganan' },
	{ label: 'Panduan', icon: 'panduan', href: '/bantuan' }
];

export function isMemberNavActive(pathname: string, href: string): boolean {
	if (href === '/dashboard') return pathname === '/dashboard';
	if (href === '/transaksi') return pathname === '/transaksi' || pathname.startsWith('/transaksi/');
	if (href === '/stok') return pathname === '/stok' || pathname.startsWith('/stok/');
	if (href === '/laporan') return pathname === '/laporan' || pathname.startsWith('/laporan/');
	if (href === '/profil') return pathname === '/profil';
	if (href === '/langganan') return pathname === '/langganan';
	if (href === '/bantuan') return pathname === '/bantuan';
	return pathname === href;
}

export function filterMemberNavItems(
	items: MemberNavItem[],
	opts: { pakaiStok: boolean }
): MemberNavItem[] {
	return items.filter((item) => !item.stokOnly || opts.pakaiStok);
}
