import { type ClassValue, clsx } from 'clsx' import { twMerge } from 'tailwind-merge' import { LC, locales } from '@/config/locales' import { env as dotEnv } from 'process' export function cn (...inputs: ClassValue[]) { return twMerge(clsx(inputs)) } export function lc (locale: string) { return LC.filter(lc => locale === lc.code)[0] } export function env (variable: string, defaultValue?: string | ''): string { return (dotEnv[variable] ?? defaultValue ?? '') } export const testPathnameRegex = ( pages: string[], pathName: string): boolean => { const pattern: string = `^(/(${locales.join('|')}))?(${pages.flatMap( (p) => (p === '/' ? ['', '/'] : p)).join('|')})/?$` //console.log(pattern) return RegExp(pattern, 'is').test(pathName) }