import { DocumentsType, DocumentVariantsValue, ImageConfig } from '@/modules/documents';
import innImage from '@/modules/documents/assets/images/documents/inn-example.svg';
import passportUzImage from '@/modules/documents/assets/images/documents/passport-uz-example.svg';
import passportTjImage from '@/modules/documents/assets/images/documents/passport-tj-example.svg';
import passportKgImage from '@/modules/documents/assets/images/documents/passport-kg-example.svg';
import fsspUzImage from '@/modules/documents/assets/images/documents/fssp-uz-example.svg';
import fsspTjImage from '@/modules/documents/assets/images/documents/fssp-tj-example.svg';
import fsspKgImage from '@/modules/documents/assets/images/documents/fssp-kg-example.svg';
import VUImage from '@/modules/documents/assets/images/documents/vu-example.svg';
import RVPImage from '@/modules/documents/assets/images/documents/rvp-example.svg';
import VNGImage from '@/modules/documents/assets/images/documents/vng-example.svg';
import MedicalBookImage from '@/modules/documents/assets/images/documents/medical-book-example.svg';
import { computed } from 'vue';
import { ELanguageLocale } from '@/UI-kit/types';

export function useDocumentImage(
    documentVariant: DocumentVariantsValue,
    currentLang: ELanguageLocale,
    customImageField?: ImageConfig,
) {
    const passportImage = computed(() => {
        if (currentLang === ELanguageLocale.KG) {
            return passportKgImage;
        }

        if (currentLang === ELanguageLocale.TJ) {
            return passportTjImage;
        }

        return passportUzImage;
    });

    const fsspImage = computed(() => {
        switch (currentLang) {
            case ELanguageLocale.KG:
                return fsspKgImage;
            case ELanguageLocale.TJ:
                return fsspTjImage;
            default:
                return fsspUzImage;
        }
    });

    const DEFAULT_IMAGES: Record<DocumentVariantsValue, ImageConfig> = {
        [DocumentsType.INN]: {
            path: innImage,
            alt: 'ИНН',
        },
        [DocumentsType.NONRESIDENT_PASSPORT]: {
            path: passportImage.value,
            alt: 'Паспорт',
        },
        [DocumentsType.DRIVERS_LICENSE]: {
            path: VUImage,
            alt: 'Водительское удостоверение',
        },
        [DocumentsType.RVP]: {
            path: RVPImage,
            alt: 'РВП',
        },
        [DocumentsType.VNG]: {
            path: VNGImage,
            alt: 'ВНЖ',
        },
        [DocumentsType.MEDICAL_BOOK]: {
            path: MedicalBookImage,
            alt: 'Медицинская книжка',
        },
        [DocumentsType.FSSP]: {
            path: fsspImage.value,
            alt: 'ФССП',
        },
        [DocumentsType.CUSTOM]: customImageField ? customImageField : ({} as ImageConfig),
    };

    return (
        DEFAULT_IMAGES[documentVariant] ||
        (customImageField?.path && DEFAULT_IMAGES[DocumentsType.CUSTOM])
    );
}
