import { authHeaders } from "./storage"; export interface TagSuggestion { value: string; count: number; } export async function searchTagSuggestions( query: string, libraryId: string, ): Promise { if (!query || query.length < 2 || !libraryId) return []; try { const response = await fetch( `/api/media-items/search?tags=${encodeURIComponent(query)}&library_id=${libraryId}&limit=20`, { headers: authHeaders() }, ); if (!response.ok) return []; const data = await response.json(); return (data.results || []) as TagSuggestion[]; } catch { return []; } }