"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const reactBinding = require("@contember/react-binding");
const createEntityConnectorFactory = (env, ...baseEntity) => {
  if (!baseEntity[baseEntity.length - 1]) {
    throw new reactBinding.BindingError('Cannot use "fileSelectionComponent" when "baseEntity" prop is not set. For more information, please consult the documentation.');
  }
  const path = baseEntity.filter(
    (it) => it !== void 0
  ).map((it) => reactBinding.QueryLanguage.desugarRelativeSingleEntity(it, env)).flatMap((it) => it.hasOneRelationPath);
  return (selected) => {
    const connector = (parent) => {
      const parentEntity = parent.getRelativeSingleEntity({
        hasOneRelationPath: path.slice(0, -1)
      });
      parentEntity.connectEntityAtField(path[path.length - 1].field, selected);
    };
    connector.entity = selected;
    return connector;
  };
};
exports.createEntityConnectorFactory = createEntityConnectorFactory;
//# sourceMappingURL=createEntityConnector.cjs.map
