"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const ui = require("@contember/ui");
const SelectFileInput = require("./selection/SelectFileInput.cjs");
const FileInput = ({
  addButtonComponent: AddButton = ui.Button,
  addButtonComponentExtraProps,
  addButtonProps,
  addButtonSubText,
  addButtonText,
  children,
  description,
  dropzoneState,
  enableAddingNew = true,
  errors,
  formatMessage,
  label,
  labelDescription,
  ...selectProps
}) => {
  const { getRootProps, isDragActive, isDragAccept, isDragReject, getInputProps } = dropzoneState;
  return /* @__PURE__ */ jsxRuntime.jsx(
    ui.FieldContainer,
    {
      label,
      useLabelElement: false,
      description,
      labelDescription,
      errors,
      children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fileInput", children: [
        children !== void 0 && children,
        enableAddingNew && /* @__PURE__ */ jsxRuntime.jsxs(
          ui.FileDropZone,
          {
            ...getRootProps(),
            isActive: isDragActive,
            isAccepting: isDragAccept,
            isRejecting: isDragReject,
            className: "fileInput-dropZone",
            children: [
              /* @__PURE__ */ jsxRuntime.jsx("input", { ...getInputProps() }),
              /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "fileInput-cta", children: [
                /* @__PURE__ */ jsxRuntime.jsxs(ui.Stack, { wrap: true, justify: "center", horizontal: true, children: [
                  selectProps.fileSelection && /* @__PURE__ */ jsxRuntime.jsx(SelectFileInput.SelectFileInput, { ...selectProps, formatMessage }),
                  /* @__PURE__ */ jsxRuntime.jsx(
                    AddButton,
                    {
                      size: "small",
                      ...addButtonComponentExtraProps,
                      ...addButtonProps,
                      children: formatMessage(addButtonText, "upload.addButton.text")
                    }
                  )
                ] }),
                /* @__PURE__ */ jsxRuntime.jsx("span", { className: "fileInput-cta-label", children: formatMessage(addButtonSubText, "upload.addButton.subText") })
              ] })
            ]
          }
        )
      ] })
    }
  );
};
exports.FileInput = FileInput;
//# sourceMappingURL=FileInput.cjs.map
