import { getChoseong } from './hangul';

export { getChoseong as getChosung };

export function searchKorean(text: string, query: string): boolean {
    if (!text || !query) return false;
    const cleanText = text.replace(/\s+/g, '').toLowerCase();
    const cleanQuery = query.replace(/\s+/g, '').toLowerCase();
    if (cleanText.includes(cleanQuery)) return true;
    const isOnlyCho = /^[ㄱ-ㅎㄲ-ㅃ]+$/.test(cleanQuery);
    if (isOnlyCho) {
        const textCho = getChoseong(cleanText);
        return textCho.includes(cleanQuery);
    }
    return false;
}
