'use client';
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { TextField } from './TextField.js';
import { RichTextField } from './RichTextField.js';
import { SlugField } from './SlugField.js';
import { SelectField } from './SelectField.js';
import { MediaField } from './MediaField.js';
import { RelationshipField } from './RelationshipField.js';
import { DateField } from './DateField.js';
import { ToggleField } from './ToggleField.js';
import { ArrayField } from './ArrayField.js';
import { BlockBuilderField } from './BlockBuilderField.js';
import { GroupField } from './GroupField.js';
import { NavBuilderField } from './NavBuilderField.js';
import { NumberField } from './NumberField.js';
import { ComponentBlockField } from './ComponentBlockField.js';
const FIELD_MAP = {
    text: TextField,
    richText: RichTextField,
    slug: SlugField,
    select: SelectField,
    media: MediaField,
    relationship: RelationshipField,
    date: DateField,
    toggle: ToggleField,
    array: ArrayField,
    blocks: BlockBuilderField,
    group: GroupField,
    nav: NavBuilderField,
    number: NumberField,
    componentBlock: ComponentBlockField,
};
export function FieldRenderer({ field, value, onChange }) {
    const Component = FIELD_MAP[field.type];
    if (!Component) {
        return (_jsxs("div", { className: "rounded-md border border-[var(--destructive)] bg-red-50 p-3 text-sm text-[var(--destructive)]", children: ["Unknown field type: ", _jsx("code", { children: field.type })] }));
    }
    return (_jsx(Component, { label: field.label, value: value, onChange: onChange, required: field.required, maxLength: field.maxLength, helpText: field.helpText, options: field.options, min: field.min, max: field.max, from: field.from, multi: field.multi, fields: field.fields, blocks: field.blocks, name: field.name, manifest: field.manifest, allow: field.allow, defaultComponent: field.defaultComponent }));
}
//# sourceMappingURL=FieldRenderer.js.map