import { ReferenceKind, Utils } from '@mikro-orm/core';
import { prepareMetadataContext, processDecoratorParameters } from '../utils.js';
/** Defines a many-to-many relationship (TC39 decorator). */
export function ManyToMany(entity, mappedBy, options = {}) {
  return function (_, context) {
    const meta = prepareMetadataContext(context, ReferenceKind.MANY_TO_MANY);
    options = processDecoratorParameters({ entity, mappedBy, options });
    const property = { name: context.name, kind: ReferenceKind.MANY_TO_MANY };
    meta.properties[context.name] ??= {};
    Utils.mergeConfig(meta.properties[context.name], property, options);
  };
}
