'use client';
import { jsxDEV as _jsxDEV, Fragment as _Fragment } from "react/jsx-dev-runtime";
import { useModal } from '@faceless-ui/modal';
import { formatAdminURL } from 'payload/shared';
import * as qs from 'qs-esm';
import React, { useCallback, useEffect, useMemo } from 'react';
import { useBulkUpload } from '../../elements/BulkUpload/index.js';
import { Button } from '../../elements/Button/index.js';
import { useDocumentDrawer } from '../../elements/DocumentDrawer/index.js';
import { Dropzone } from '../../elements/Dropzone/index.js';
import { useListDrawer } from '../../elements/ListDrawer/index.js';
import { RenderCustomComponent } from '../../elements/RenderCustomComponent/index.js';
import { ShimmerEffect } from '../../elements/ShimmerEffect/index.js';
import { FieldDescription } from '../../fields/FieldDescription/index.js';
import { FieldError } from '../../fields/FieldError/index.js';
import { FieldLabel } from '../../fields/FieldLabel/index.js';
import { useAuth } from '../../providers/Auth/index.js';
import { useLocale } from '../../providers/Locale/index.js';
import { useTranslation } from '../../providers/Translation/index.js';
import { normalizeRelationshipValue } from '../../utilities/normalizeRelationshipValue.js';
import { fieldBaseClass } from '../shared/index.js';
import { UploadComponentHasMany } from './HasMany/index.js';
import './index.scss';
import { UploadComponentHasOne } from './HasOne/index.js';
export const baseClass = 'upload';
/**
   * Controls the visibility of the "Create new collection" button
   */ export function UploadInput(props) {
    const { AfterInput, allowCreate, api, BeforeInput, className, Description, description, displayPreview, Error, filterOptions: filterOptionsFromProps, hasMany, isSortable, Label, label, localized, maxRows, onChange: onChangeFromProps, path, readOnly, relationTo, required, serverURL, showError, style, value } = props;
    const [populatedDocs, setPopulatedDocs] = React.useState();
    const [activeRelationTo] = React.useState(Array.isArray(relationTo) ? relationTo[0] : relationTo);
    const { openModal } = useModal();
    const { drawerSlug, setCollectionSlug, setInitialFiles, setMaxFiles, setOnSuccess, setSelectableCollections } = useBulkUpload();
    const { permissions } = useAuth();
    const { code } = useLocale();
    const { i18n, t } = useTranslation();
    // This will be used by the bulk upload to allow you to select only collections you have create permissions for
    const collectionSlugsWithCreatePermission = useMemo(()=>{
        if (Array.isArray(relationTo)) {
            return relationTo.filter((relation)=>permissions?.collections && permissions.collections?.[relation]?.create);
        }
        return [];
    }, [
        relationTo,
        permissions
    ]);
    const filterOptions = useMemo(()=>{
        const isPoly = Array.isArray(relationTo);
        if (!value) {
            return filterOptionsFromProps;
        }
        // Group existing IDs by relation
        const existingIdsByRelation = {};
        const values = Array.isArray(value) ? value : [
            value
        ];
        for (const val of values){
            if (isPoly && typeof val === 'object' && 'relationTo' in val) {
                // Poly upload - group by relationTo
                if (!existingIdsByRelation[val.relationTo]) {
                    existingIdsByRelation[val.relationTo] = [];
                }
                existingIdsByRelation[val.relationTo].push(val.value);
            } else if (!isPoly) {
                // Non-poly upload - all IDs belong to the single collection
                const collection = relationTo;
                if (!existingIdsByRelation[collection]) {
                    existingIdsByRelation[collection] = [];
                }
                const id = typeof val === 'object' && 'value' in val ? val.value : val;
                if (typeof id === 'string' || typeof id === 'number') {
                    existingIdsByRelation[collection].push(id);
                }
            }
        }
        // Build filter options for each collection
        const newFilterOptions = {
            ...filterOptionsFromProps
        };
        const relations = isPoly ? relationTo : [
            relationTo
        ];
        relations.forEach((relation)=>{
            const existingIds = existingIdsByRelation[relation] || [];
            newFilterOptions[relation] = {
                ...filterOptionsFromProps?.[relation] || {},
                id: {
                    ...filterOptionsFromProps?.[relation]?.id || {},
                    not_in: (filterOptionsFromProps?.[relation]?.id?.not_in || []).concat(existingIds)
                }
            };
        });
        return newFilterOptions;
    }, [
        value,
        filterOptionsFromProps,
        relationTo
    ]);
    const [ListDrawer, , { closeDrawer: closeListDrawer, openDrawer: openListDrawer }] = useListDrawer({
        collectionSlugs: typeof relationTo === 'string' ? [
            relationTo
        ] : relationTo,
        filterOptions
    });
    const [CreateDocDrawer, , { closeDrawer: closeCreateDocDrawer, openDrawer: openCreateDocDrawer }] = useDocumentDrawer({
        collectionSlug: activeRelationTo
    });
    /**
   * Track the last loaded value to prevent unnecessary reloads
   */ const loadedValueRef = React.useRef(null);
    const canCreate = useMemo(()=>{
        if (!allowCreate) {
            return false;
        }
        if (typeof activeRelationTo === 'string') {
            if (permissions?.collections && permissions.collections?.[activeRelationTo]?.create) {
                return true;
            }
        }
        return false;
    }, [
        activeRelationTo,
        permissions,
        allowCreate
    ]);
    const onChange = React.useCallback((newValue)=>{
        if (typeof onChangeFromProps === 'function') {
            onChangeFromProps(newValue);
        }
    }, [
        onChangeFromProps
    ]);
    const populateDocs = React.useCallback(async (items)=>{
        if (!items?.length) {
            return [];
        }
        // 1. Group IDs by collection
        const grouped = {};
        items.forEach(({ relationTo, value })=>{
            if (!grouped[relationTo]) {
                grouped[relationTo] = [];
            }
            // Ensure we extract the actual ID value, not an object
            let idValue = value;
            if (value && typeof value === 'object' && 'value' in value) {
                idValue = value.value;
            }
            grouped[relationTo].push(idValue);
        });
        // 2. Fetch per collection
        const fetches = Object.entries(grouped).map(async ([collection, ids])=>{
            const query = {
                depth: 0,
                draft: true,
                limit: ids.length,
                locale: code,
                where: {
                    and: [
                        {
                            id: {
                                in: ids
                            }
                        }
                    ]
                }
            };
            const response = await fetch(formatAdminURL({
                apiRoute: api,
                path: `/${collection}`
            }), {
                body: qs.stringify(query),
                credentials: 'include',
                headers: {
                    'Accept-Language': i18n.language,
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'X-Payload-HTTP-Method-Override': 'GET'
                },
                method: 'POST'
            });
            let docs = [];
            if (response.ok) {
                const data = await response.json();
                docs = data.docs;
            }
            // Map docs by ID for fast lookup
            const docsById = docs.reduce((acc, doc)=>{
                acc[doc.id] = doc;
                return acc;
            }, {});
            return {
                collection,
                docsById
            };
        });
        const results = await Promise.all(fetches);
        // 3. Build lookup
        const lookup = {};
        results.forEach(({ collection, docsById })=>{
            lookup[collection] = docsById;
        });
        // 4. Reconstruct in input order, add placeholders if missing
        const sortedDocs = items.map(({ relationTo, value })=>{
            const doc = lookup[relationTo]?.[value] || {
                id: value,
                filename: `${t('general:untitled')} - ID: ${value}`,
                isPlaceholder: true
            };
            return {
                relationTo,
                value: doc
            };
        });
        return sortedDocs;
    }, [
        api,
        code,
        i18n.language,
        t
    ]);
    const normalizeValue = useCallback((value)=>normalizeRelationshipValue(value, relationTo), [
        relationTo
    ]);
    const onUploadSuccess = useCallback((uploadedForms)=>{
        const isPoly = Array.isArray(relationTo);
        if (hasMany) {
            const newValues = uploadedForms.map((form)=>isPoly ? {
                    relationTo: form.collectionSlug,
                    value: form.doc.id
                } : form.doc.id);
            // Normalize existing values before merging
            const normalizedExisting = Array.isArray(value) ? value.map(normalizeValue) : [];
            const mergedValue = [
                ...normalizedExisting,
                ...newValues
            ];
            onChange(mergedValue);
            setPopulatedDocs((currentDocs)=>[
                    ...currentDocs || [],
                    ...uploadedForms.map((form)=>({
                            relationTo: form.collectionSlug,
                            value: form.doc
                        }))
                ]);
        } else {
            const firstDoc = uploadedForms[0];
            const newValue = isPoly ? {
                relationTo: firstDoc.collectionSlug,
                value: firstDoc.doc.id
            } : firstDoc.doc.id;
            onChange(newValue);
            setPopulatedDocs([
                {
                    relationTo: firstDoc.collectionSlug,
                    value: firstDoc.doc
                }
            ]);
        }
    }, [
        value,
        onChange,
        hasMany,
        relationTo,
        normalizeValue
    ]);
    const onLocalFileSelection = React.useCallback((fileList)=>{
        let fileListToUse = fileList;
        if (!hasMany && fileList && fileList.length > 1) {
            const dataTransfer = new DataTransfer();
            dataTransfer.items.add(fileList[0]);
            fileListToUse = dataTransfer.files;
        }
        if (fileListToUse) {
            setInitialFiles(fileListToUse);
        }
        // Use activeRelationTo for poly uploads, or relationTo as string for single collection
        const collectionToUse = Array.isArray(relationTo) ? activeRelationTo : relationTo;
        setCollectionSlug(collectionToUse);
        if (Array.isArray(collectionSlugsWithCreatePermission)) {
            setSelectableCollections(collectionSlugsWithCreatePermission);
        }
        if (typeof maxRows === 'number') {
            setMaxFiles(maxRows);
        }
        openModal(drawerSlug);
    }, [
        hasMany,
        relationTo,
        activeRelationTo,
        setCollectionSlug,
        collectionSlugsWithCreatePermission,
        maxRows,
        openModal,
        drawerSlug,
        setInitialFiles,
        setSelectableCollections,
        setMaxFiles
    ]);
    // only hasMany can bulk select
    const onListBulkSelect = React.useCallback(async (docs)=>{
        const isPoly = Array.isArray(relationTo);
        const selectedDocIDs = [];
        for (const [id, isSelected] of docs){
            if (isSelected) {
                selectedDocIDs.push(id);
            }
        }
        const itemsToLoad = selectedDocIDs.map((id)=>({
                relationTo: activeRelationTo,
                value: id
            }));
        const loadedDocs = await populateDocs(itemsToLoad);
        if (loadedDocs) {
            setPopulatedDocs((currentDocs)=>[
                    ...currentDocs || [],
                    ...loadedDocs
                ]);
        }
        const newValues = selectedDocIDs.map((id)=>isPoly ? {
                relationTo: activeRelationTo,
                value: id
            } : id);
        // Normalize existing values before merging
        const normalizedExisting = Array.isArray(value) ? value.map(normalizeValue) : [];
        onChange([
            ...normalizedExisting,
            ...newValues
        ]);
        closeListDrawer();
    }, [
        activeRelationTo,
        closeListDrawer,
        onChange,
        populateDocs,
        value,
        relationTo,
        normalizeValue
    ]);
    const onDocCreate = React.useCallback((data)=>{
        const isPoly = Array.isArray(relationTo);
        if (data.doc) {
            setPopulatedDocs((currentDocs)=>[
                    ...currentDocs || [],
                    {
                        relationTo: activeRelationTo,
                        value: data.doc
                    }
                ]);
            const newValue = isPoly ? {
                relationTo: activeRelationTo,
                value: data.doc.id
            } : data.doc.id;
            onChange(newValue);
        }
        closeCreateDocDrawer();
    }, [
        closeCreateDocDrawer,
        activeRelationTo,
        onChange,
        relationTo
    ]);
    const onListSelect = useCallback(async ({ collectionSlug, doc })=>{
        const isPoly = Array.isArray(relationTo);
        const loadedDocs = await populateDocs([
            {
                relationTo: collectionSlug,
                value: doc.id
            }
        ]);
        const selectedDoc = loadedDocs?.[0] || null;
        setPopulatedDocs((currentDocs)=>{
            if (selectedDoc) {
                if (hasMany) {
                    return [
                        ...currentDocs || [],
                        selectedDoc
                    ];
                }
                return [
                    selectedDoc
                ];
            }
            return currentDocs;
        });
        if (hasMany) {
            const newValue = isPoly ? {
                relationTo: collectionSlug,
                value: doc.id
            } : doc.id;
            // Normalize existing values before merging
            const normalizedExisting = Array.isArray(value) ? value.map(normalizeValue) : [];
            const valueToUse = [
                ...normalizedExisting,
                newValue
            ];
            onChange(valueToUse);
        } else {
            const valueToUse = isPoly ? {
                relationTo: collectionSlug,
                value: doc.id
            } : doc.id;
            onChange(valueToUse);
        }
        closeListDrawer();
    }, [
        closeListDrawer,
        hasMany,
        populateDocs,
        onChange,
        value,
        relationTo,
        normalizeValue
    ]);
    const reloadDoc = React.useCallback(async (docID, collectionSlug)=>{
        const docs = await populateDocs([
            {
                relationTo: collectionSlug,
                value: docID
            }
        ]);
        if (docs[0]) {
            let updatedDocsToPropogate = [];
            setPopulatedDocs((currentDocs)=>{
                const existingDocIndex = currentDocs?.findIndex((doc)=>{
                    const hasExisting = doc.value?.id === docs[0].value.id || doc.value?.isPlaceholder;
                    return hasExisting && doc.relationTo === collectionSlug;
                });
                if (existingDocIndex > -1) {
                    const updatedDocs = [
                        ...currentDocs
                    ];
                    updatedDocs[existingDocIndex] = docs[0];
                    updatedDocsToPropogate = updatedDocs;
                    return updatedDocs;
                }
                return currentDocs;
            });
            if (updatedDocsToPropogate.length && hasMany) {
                onChange(updatedDocsToPropogate.map((doc)=>doc.value?.id));
            }
        }
    }, [
        populateDocs,
        onChange,
        hasMany
    ]);
    // only hasMany can reorder
    const onReorder = React.useCallback((newValue)=>{
        const isPoly = Array.isArray(relationTo);
        const newValueToSave = newValue.map(({ relationTo: rel, value })=>isPoly ? {
                relationTo: rel,
                value: value.id
            } : value.id);
        onChange(newValueToSave);
        setPopulatedDocs(newValue);
    }, [
        onChange,
        relationTo
    ]);
    const onRemove = React.useCallback((newValue)=>{
        const isPoly = Array.isArray(relationTo);
        if (!newValue || newValue.length === 0) {
            onChange(hasMany ? [] : null);
            setPopulatedDocs(hasMany ? [] : null);
            return;
        }
        const newValueToSave = newValue.map(({ relationTo: rel, value })=>isPoly ? {
                relationTo: rel,
                value: value.id
            } : value.id);
        onChange(hasMany ? newValueToSave : newValueToSave[0]);
        setPopulatedDocs(newValue);
    }, [
        onChange,
        hasMany,
        relationTo
    ]);
    useEffect(()=>{
        async function loadInitialDocs() {
            if (value) {
                let itemsToLoad = [];
                if (Array.isArray(relationTo) && (typeof value === 'object' && 'relationTo' in value || Array.isArray(value) && value.length > 0 && typeof value[0] === 'object' && 'relationTo' in value[0])) {
                    // For poly uploads, value should already be in the format { relationTo, value }
                    const values = Array.isArray(value) ? value : [
                        value
                    ];
                    itemsToLoad = values.filter((v)=>typeof v === 'object' && 'relationTo' in v).map((v)=>{
                        // Ensure the value property is a simple ID, not nested
                        let idValue = v.value;
                        while(idValue && typeof idValue === 'object' && idValue !== null && 'value' in idValue){
                            idValue = idValue.value;
                        }
                        return {
                            relationTo: v.relationTo,
                            value: idValue
                        };
                    });
                } else {
                    // This check is here to satisfy TypeScript that relationTo is a string
                    if (!Array.isArray(relationTo)) {
                        // For single collection uploads, we need to wrap the IDs
                        const ids = Array.isArray(value) ? value : [
                            value
                        ];
                        itemsToLoad = ids.map((id)=>{
                            // Extract the actual ID, handling nested objects
                            let idValue = id;
                            while(idValue && typeof idValue === 'object' && idValue !== null && 'value' in idValue){
                                idValue = idValue.value;
                            }
                            return {
                                relationTo,
                                value: idValue
                            };
                        });
                    }
                }
                if (itemsToLoad.length > 0) {
                    const loadedDocs = await populateDocs(itemsToLoad);
                    if (loadedDocs) {
                        setPopulatedDocs(loadedDocs);
                        loadedValueRef.current = value;
                    }
                }
            } else {
                // Clear populated docs when value is cleared
                setPopulatedDocs([]);
                loadedValueRef.current = null;
            }
        }
        // Only load if value has changed from what we last loaded
        const valueChanged = loadedValueRef.current !== value;
        if (valueChanged) {
            void loadInitialDocs();
        }
    }, [
        populateDocs,
        value,
        relationTo
    ]);
    useEffect(()=>{
        setOnSuccess(onUploadSuccess);
    }, [
        value,
        path,
        onUploadSuccess,
        setOnSuccess
    ]);
    const showDropzone = !value || hasMany && Array.isArray(value) && (typeof maxRows !== 'number' || value.length < maxRows) || !hasMany && populatedDocs?.[0] && typeof populatedDocs[0].value === 'undefined';
    return /*#__PURE__*/ _jsxDEV("div", {
        className: [
            fieldBaseClass,
            baseClass,
            className,
            showError && 'error',
            readOnly && 'read-only'
        ].filter(Boolean).join(' '),
        id: `field-${path?.replace(/\./g, '__')}`,
        style: style,
        children: [
            /*#__PURE__*/ _jsxDEV(RenderCustomComponent, {
                CustomComponent: Label,
                Fallback: /*#__PURE__*/ _jsxDEV(FieldLabel, {
                    label: label,
                    localized: localized,
                    path: path,
                    required: required
                }, void 0, false, {
                    fileName: "src/fields/Upload/Input.tsx",
                    lineNumber: 664,
                    columnNumber: 11
                }, void 0)
            }, void 0, false, {
                fileName: "src/fields/Upload/Input.tsx",
                lineNumber: 661,
                columnNumber: 7
            }, this),
            /*#__PURE__*/ _jsxDEV("div", {
                className: `${baseClass}__wrap`,
                children: /*#__PURE__*/ _jsxDEV(RenderCustomComponent, {
                    CustomComponent: Error,
                    Fallback: /*#__PURE__*/ _jsxDEV(FieldError, {
                        path: path,
                        showError: showError
                    }, void 0, false, {
                        fileName: "src/fields/Upload/Input.tsx",
                        lineNumber: 670,
                        columnNumber: 21
                    }, void 0)
                }, void 0, false, {
                    fileName: "src/fields/Upload/Input.tsx",
                    lineNumber: 668,
                    columnNumber: 9
                }, this)
            }, void 0, false, {
                fileName: "src/fields/Upload/Input.tsx",
                lineNumber: 667,
                columnNumber: 7
            }, this),
            BeforeInput,
            /*#__PURE__*/ _jsxDEV("div", {
                className: `${baseClass}__dropzoneAndUpload`,
                children: [
                    hasMany && Array.isArray(value) && value.length > 0 ? /*#__PURE__*/ _jsxDEV(_Fragment, {
                        children: populatedDocs && populatedDocs?.length > 0 ? /*#__PURE__*/ _jsxDEV(UploadComponentHasMany, {
                            displayPreview: displayPreview,
                            fileDocs: populatedDocs,
                            isSortable: isSortable && !readOnly,
                            onRemove: onRemove,
                            onReorder: onReorder,
                            readonly: readOnly,
                            reloadDoc: reloadDoc,
                            serverURL: serverURL,
                            showCollectionSlug: Array.isArray(relationTo)
                        }, void 0, false, {
                            fileName: "src/fields/Upload/Input.tsx",
                            lineNumber: 678,
                            columnNumber: 15
                        }, this) : /*#__PURE__*/ _jsxDEV("div", {
                            className: `${baseClass}__loadingRows`,
                            children: value.map((id)=>/*#__PURE__*/ _jsxDEV(ShimmerEffect, {
                                    height: "40px"
                                }, typeof id === 'object' ? id.value : id, false, {
                                    fileName: "src/fields/Upload/Input.tsx",
                                    lineNumber: 692,
                                    columnNumber: 19
                                }, this))
                        }, void 0, false, {
                            fileName: "src/fields/Upload/Input.tsx",
                            lineNumber: 690,
                            columnNumber: 15
                        }, this)
                    }, void 0, false) : null,
                    !hasMany && value ? /*#__PURE__*/ _jsxDEV(_Fragment, {
                        children: populatedDocs && populatedDocs?.length > 0 && populatedDocs[0].value ? /*#__PURE__*/ _jsxDEV(UploadComponentHasOne, {
                            displayPreview: displayPreview,
                            fileDoc: populatedDocs[0],
                            onRemove: onRemove,
                            readonly: readOnly,
                            reloadDoc: reloadDoc,
                            serverURL: serverURL,
                            showCollectionSlug: Array.isArray(relationTo)
                        }, void 0, false, {
                            fileName: "src/fields/Upload/Input.tsx",
                            lineNumber: 701,
                            columnNumber: 15
                        }, this) : populatedDocs && value && !populatedDocs?.[0]?.value ? /*#__PURE__*/ _jsxDEV(_Fragment, {
                            children: [
                                t('general:untitled'),
                                " - ID: ",
                                value
                            ]
                        }, void 0, true) : /*#__PURE__*/ _jsxDEV(ShimmerEffect, {
                            height: "62px"
                        }, void 0, false, {
                            fileName: "src/fields/Upload/Input.tsx",
                            lineNumber: 715,
                            columnNumber: 15
                        }, this)
                    }, void 0, false) : null,
                    showDropzone ? /*#__PURE__*/ _jsxDEV(Dropzone, {
                        disabled: readOnly || !canCreate,
                        multipleFiles: hasMany,
                        onChange: onLocalFileSelection,
                        children: /*#__PURE__*/ _jsxDEV("div", {
                            className: `${baseClass}__dropzoneContent`,
                            children: [
                                /*#__PURE__*/ _jsxDEV("div", {
                                    className: `${baseClass}__dropzoneContent__buttons`,
                                    children: [
                                        canCreate && /*#__PURE__*/ _jsxDEV(_Fragment, {
                                            children: [
                                                /*#__PURE__*/ _jsxDEV(Button, {
                                                    buttonStyle: "pill",
                                                    className: `${baseClass}__createNewToggler`,
                                                    disabled: readOnly || !canCreate,
                                                    onClick: ()=>{
                                                        if (!readOnly) {
                                                            if (hasMany) {
                                                                onLocalFileSelection();
                                                            } else {
                                                                openCreateDocDrawer();
                                                            }
                                                        }
                                                    },
                                                    size: "small",
                                                    children: t('general:createNew')
                                                }, void 0, false, {
                                                    fileName: "src/fields/Upload/Input.tsx",
                                                    lineNumber: 729,
                                                    columnNumber: 21
                                                }, this),
                                                /*#__PURE__*/ _jsxDEV("span", {
                                                    className: `${baseClass}__dropzoneContent__orText`,
                                                    children: t('general:or')
                                                }, void 0, false, {
                                                    fileName: "src/fields/Upload/Input.tsx",
                                                    lineNumber: 746,
                                                    columnNumber: 21
                                                }, this)
                                            ]
                                        }, void 0, true),
                                        /*#__PURE__*/ _jsxDEV(Button, {
                                            buttonStyle: "pill",
                                            className: `${baseClass}__listToggler`,
                                            disabled: readOnly,
                                            onClick: openListDrawer,
                                            size: "small",
                                            children: t('fields:chooseFromExisting')
                                        }, void 0, false, {
                                            fileName: "src/fields/Upload/Input.tsx",
                                            lineNumber: 751,
                                            columnNumber: 17
                                        }, this),
                                        /*#__PURE__*/ _jsxDEV(CreateDocDrawer, {
                                            onSave: onDocCreate
                                        }, void 0, false, {
                                            fileName: "src/fields/Upload/Input.tsx",
                                            lineNumber: 760,
                                            columnNumber: 17
                                        }, this),
                                        /*#__PURE__*/ _jsxDEV(ListDrawer, {
                                            allowCreate: canCreate,
                                            enableRowSelections: hasMany,
                                            onBulkSelect: onListBulkSelect,
                                            onSelect: onListSelect
                                        }, void 0, false, {
                                            fileName: "src/fields/Upload/Input.tsx",
                                            lineNumber: 761,
                                            columnNumber: 17
                                        }, this)
                                    ]
                                }, void 0, true, {
                                    fileName: "src/fields/Upload/Input.tsx",
                                    lineNumber: 726,
                                    columnNumber: 15
                                }, this),
                                canCreate && !readOnly && /*#__PURE__*/ _jsxDEV("p", {
                                    className: `${baseClass}__dragAndDropText`,
                                    children: [
                                        t('general:or'),
                                        " ",
                                        t('upload:dragAndDrop')
                                    ]
                                }, void 0, true, {
                                    fileName: "src/fields/Upload/Input.tsx",
                                    lineNumber: 770,
                                    columnNumber: 17
                                }, this)
                            ]
                        }, void 0, true, {
                            fileName: "src/fields/Upload/Input.tsx",
                            lineNumber: 725,
                            columnNumber: 13
                        }, this)
                    }, void 0, false, {
                        fileName: "src/fields/Upload/Input.tsx",
                        lineNumber: 720,
                        columnNumber: 11
                    }, this) : /*#__PURE__*/ _jsxDEV(_Fragment, {
                        children: !readOnly && !populatedDocs && (!value || typeof maxRows !== 'number' || Array.isArray(value) && value.length < maxRows) ? /*#__PURE__*/ _jsxDEV(ShimmerEffect, {
                            height: "40px"
                        }, void 0, false, {
                            fileName: "src/fields/Upload/Input.tsx",
                            lineNumber: 783,
                            columnNumber: 15
                        }, this) : null
                    }, void 0, false)
                ]
            }, void 0, true, {
                fileName: "src/fields/Upload/Input.tsx",
                lineNumber: 674,
                columnNumber: 7
            }, this),
            AfterInput,
            /*#__PURE__*/ _jsxDEV(RenderCustomComponent, {
                CustomComponent: Description,
                Fallback: /*#__PURE__*/ _jsxDEV(FieldDescription, {
                    description: description,
                    path: path
                }, void 0, false, {
                    fileName: "src/fields/Upload/Input.tsx",
                    lineNumber: 791,
                    columnNumber: 19
                }, void 0)
            }, void 0, false, {
                fileName: "src/fields/Upload/Input.tsx",
                lineNumber: 789,
                columnNumber: 7
            }, this)
        ]
    }, void 0, true, {
        fileName: "src/fields/Upload/Input.tsx",
        lineNumber: 648,
        columnNumber: 5
    }, this);
}

//# sourceMappingURL=Input.js.map