import { useCallback, createElement } from "react";
import { Component, useEnvironment } from "@contember/binding";
import { BareUploadField } from "./BareUploadField.js";
import { useResolvedSingleKindFileSelection } from "./selection/useResolvedSingleKindFileSelection.js";
import { createEntityConnectorFactory } from "../fileHandler/utils/createEntityConnector.js";
import { useSingleKindFileHandler } from "../fileHandler/useSingleKindFileHandler.js";
import { SingleKindFileHandler, isEmptyByUrlField } from "../fileHandler/SingleKindFileHandler.js";
const SingleKindUploadField = Component((props) => {
  const env = useEnvironment();
  const connectorFactoryFactory = useCallback(() => createEntityConnectorFactory(env, props.baseEntity), [env, props.baseEntity]);
  return /* @__PURE__ */ createElement(BareUploadField, {
    ...props,
    fileSelection: useResolvedSingleKindFileSelection(props, connectorFactoryFactory),
    fileHandler: useSingleKindFileHandler(props, props.kindFactory)
  });
}, (props) => /* @__PURE__ */ createElement(BareUploadField, {
  ...props,
  fileHandler: new SingleKindFileHandler(props.kindFactory(props), isEmptyByUrlField(props.urlField))
}), "SingleKindUploadField");
export { SingleKindUploadField };
//# sourceMappingURL=SingleKindUploadField.js.map
