import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
import { useRef } from 'react';
import classNames from '../../_virtual/index.js';
import Button from '../Button/Button.js';
import Typography from '../Typography/Typography.js';
import RadioGroup from '../RadioGroup/RadioGroup.js';
import RadioFilePreview from './RadioFilePreview.js';

const Dropzone = ({ icon, primaryLabel, secondaryLabel, buttonLabel, getRootProps, getInputProps, isDragActive = false, height = 188, isWebServiceFileDropZone = false, selectedRadioOption, radioOptions, handleOptionChange, selectedFile, setSelectedFile, handleRemoveFile, isDisable, setShowDrawer, setFileContent, }) => {
    const isWebServiceFile = selectedFile?.name && isWebServiceFileDropZone;
    const inputRef = useRef(null);
    const handleOnClick = (e) => {
        if (!isDisable && inputRef.current) {
            inputRef.current.click();
            e.currentTarget.blur();
        }
    };
    return (jsx("div", { ...getRootProps(), className: classNames('ff-file-dropzone', {
            'ff-file-dropzone--active': isDragActive,
            'ff-file-dropzone--webservice-file': isWebServiceFile,
            'ff-file-dropzone--webservice-container': isWebServiceFileDropZone,
            'ff-disable-file-dropzone-wrapper': isDisable,
        }), style: { height: height }, children: isWebServiceFile ? (jsx(RadioFilePreview, { selectedFile: selectedFile.name, onFileRemoveClick: handleRemoveFile, onFileReplaceClick: setSelectedFile, setSelectedFile: setSelectedFile, selectedRadioOption: selectedRadioOption, setShowDrawer: setShowDrawer, setFileContent: setFileContent })) : (jsxs(Fragment, { children: [jsx("div", { className: "ff-file-dropzone-content__icon", children: icon }), jsxs("div", { className: "ff-file-dropzone-content__labels", children: [jsx(Typography, { as: "p", fontWeight: "semi-bold", lineHeight: "18px", textAlign: "center", color: 'var(--text-color)', children: primaryLabel }), jsx(Typography, { as: "p", lineHeight: "18px", textAlign: "center", color: 'var(--text-color)', children: secondaryLabel }), isWebServiceFileDropZone ? (jsxs("div", { className: "ff-radio-group-wrapper", children: [jsxs(Typography, { fontWeight: "semi-bold", children: [' ', "Choose file from", ' '] }), jsx(RadioGroup, { name: "radio_btn_file_dropzone", options: radioOptions ?? [
                                        { label: 'Default Label', value: 'default_value' },
                                    ], selectedValue: selectedRadioOption?.value, onChange: handleOptionChange })] })) : (jsx(Button, { variant: "primary", label: buttonLabel, className: "choose-file-btn", disabled: isDisable, onClick: handleOnClick, children: jsx("input", { ref: inputRef, ...(isDisable
                                    ? { style: { cursor: 'not-allowed' }, disabled: true }
                                    : getInputProps()), title: "", "aria-label": "", style: { display: 'none' } }) }))] })] })) }));
};

export { Dropzone as default };
//# sourceMappingURL=Dropzone.js.map
