import { ReferenceKind } from '@mikro-orm/core';
import { processDecoratorParameters, validateSingleDecorator, getMetadataFromDecorator } from '../utils.js';
export function ManyToMany(entity, mappedBy, options = {}) {
  return function (target, propertyName) {
    options = processDecoratorParameters({ entity, mappedBy, options });
    const meta = getMetadataFromDecorator(target.constructor);
    validateSingleDecorator(meta, propertyName, ReferenceKind.MANY_TO_MANY);
    const property = { name: propertyName, kind: ReferenceKind.MANY_TO_MANY };
    meta.properties[propertyName] = Object.assign(meta.properties[propertyName] ?? {}, property, options);
  };
}
