export type UploadCategory = 'all' | 'image' | 'video' | 'text';

export const categoryConfig: Record<UploadCategory, { label: string }> = {
  all: { label: '전체' },
  image: { label: 'Image' },
  video: { label: 'Video' },
  text: { label: 'Text' },
};

export const categoryBadge: Record<'image' | 'video' | 'text', string> = {
  image: 'bg-brand-tint-purple text-brand-purple-muted shadow-[2px_3px_6px_rgba(155,138,212,0.12)]',
  video: 'bg-brand-rose-bg text-brand-rose shadow-[2px_3px_6px_rgba(212,136,154,0.12)]',
  text: 'bg-brand-earth-bg text-brand-earth shadow-[2px_3px_6px_rgba(212,168,114,0.12)]',
};

export const ACCEPT_MAP: Record<string, string> = {
  'image/*': '.jpg,.jpeg,.png,.gif,.webp,.svg',
  'video/*': '.mp4,.mov,.webm,.avi',
  'text/*': '.txt,.md,.doc,.docx,.pdf,.csv,.json',
};

export const ALL_ACCEPT = Object.values(ACCEPT_MAP).join(',');

export function categorize(file: File): 'image' | 'video' | 'text' {
  if (file.type.startsWith('image/')) return 'image';
  if (file.type.startsWith('video/')) return 'video';
  return 'text';
}

export function formatSize(bytes: number): string {
  if (bytes >= 1_048_576) return `${(bytes / 1_048_576).toFixed(1)} MB`;
  if (bytes >= 1024) return `${Math.round(bytes / 1024)} KB`;
  return `${bytes} B`;
}

export function uid() {
  return `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
}
