import { LangsBDEFHIJPRZEnum } from '@/api/types';

import { Lang } from './Lang';

const MASK_CHAR = '▓';

const maskText = (text: string): string => {
    const length = [...text].length;
    if (length === 0) return '';
    return MASK_CHAR.repeat(Math.ceil(length / 2));
};

export const resolveLLText = (
    value: string | number,
    lang: LangsBDEFHIJPRZEnum,
): string => {
    const text = String(value);
    if (lang === 'ru') return text;
    // TODO: server translation lookup by `text` + `lang`
    return maskText(text);
};

export const LLRender = (value: string | number | undefined): string => {

    if (!value) return '';

    return resolveLLText(value, Lang.getCurrentLang());
}
