import * as React from 'react';
import { IRecommendation } from './utils';
import './Recommendation.scss';
import { getType } from '../../utils';
import { FaEyeSlash } from 'react-icons/fa';
import { NewLightboxView } from '../../NewLightboxView';
import { DocumentManager } from '../../../../util/DocumentManager';
import { Doc } from '../../../../../fields/Doc';
import { Docs } from '../../../../documents/Documents';
export const Recommendation = (props: IRecommendation) => {
    const { title, data, type, text, transcript, loading, source, previewUrl, related_concepts, distance, docId } = props;
    return (
        
 {
                let doc: Doc | null = null;
                if (source == 'Dash' && docId) {
                    const docView = DocumentManager.Instance.getDocumentViewsById(docId).lastElement();
                    if (docView) {
                        doc = docView.Document;
                    }
                } else if (data) {
                    switch (type) {
                        case 'YouTube':
                            console.log('create ', type, 'document');
                            doc = Docs.Create.VideoDocument(data, { title: title, _width: 400, _height: 315 });
                            doc.transcript = transcript ? JSON.stringify(transcript) : undefined;
                            break;
                        case 'Video':
                            console.log('create ', type, 'document');
                            doc = Docs.Create.VideoDocument(data, { title: title, _width: 400, _height: 315 });
                            doc.transcript = transcript ? JSON.stringify(transcript) : undefined;
                            break;
                        case 'Webpage':
                            console.log('create ', type, 'document');
                            doc = Docs.Create.WebDocument(data, { title: title, text: text });
                            break;
                        case 'HTML':
                            console.log('create ', type, 'document');
                            doc = Docs.Create.WebDocument(data, { title: title, text: text });
                            break;
                        case 'Text':
                            console.log('create ', type, 'document');
                            doc = Docs.Create.TextDocument(data, { title: title, text: text });
                            break;
                        case 'PDF':
                            console.log('create ', type, 'document');
                            doc = Docs.Create.PdfDocument(data, { title: title, text: text });
                            break;
                    }
                }
                if (doc !== null) NewLightboxView.SetNewLightboxDoc(doc);
            }}>
            {loading ? 
 : previewUrl ? 
{

}
 : null}
            
{title}
            
                {!loading && (
                    
                )}
                {!loading && (
                    
                )}
            
                {!loading && (
                    
                        You are seeing this recommendation because this document also explores
                        
                            {related_concepts?.map(val => {
                                return 
{val}
;
                            })}
                        
                )}
            
                {!loading && (
                    <>
                        
Hide Recommendation
                        
                            
                        
                    >
                )}