import { createElement } from "react";
import { SugaredField, QueryLanguage } from "@contember/binding";
const getFileUrlDataExtractor = ({ urlField }) => ({
  staticRender: () => /* @__PURE__ */ createElement(SugaredField, {
    field: urlField
  }),
  populateFields: ({ entity, uploadResult }) => {
    if (!uploadResult.fileUrl || typeof uploadResult.fileUrl !== "string") {
      return;
    }
    entity.getField(urlField).updateValue(uploadResult.fileUrl);
  },
  getErrorsHolders: ({ entity, environment }) => {
    const desugaredUrlField = QueryLanguage.desugarRelativeSingleField(urlField, environment);
    const owningEntity = entity.getRelativeSingleEntity({
      hasOneRelationPath: desugaredUrlField.hasOneRelationPath
    });
    return [entity.getField(urlField), owningEntity];
  }
});
export { getFileUrlDataExtractor };
//# sourceMappingURL=getFileUrlDataExtractor.js.map
