import React from 'react';
import { CellReferenceView } from '@wix/patterns-fields';
import { CellViewLayout } from '../CellViewLayout';
import { getImageFieldId } from './getImageFieldId';
export const ReferenceView = ({ value, typeConfig, }) => {
    const config = typeConfig;
    if (!value || !config?.refSchema) {
        return React.createElement(CellViewLayout, null, null);
    }
    const { displayField, fields } = config.refSchema;
    const imageField = getImageFieldId(fields);
    const name = String(value[displayField] ?? '');
    const imageUrl = imageField
        ? value[imageField]
        : undefined;
    return (React.createElement(CellReferenceView, { name: name, imageUrl: imageUrl, dataHook: "reference-view" }));
};
//# sourceMappingURL=View.js.map