import { ReferenceKind } from '@mikro-orm/core';
import { prepareMetadataContext, processDecoratorParameters } from '../utils.js';
/** Defines a one-to-one relationship (TC39 decorator). */
export function OneToOne(entity, mappedByOrOptions, options = {}) {
  const mappedBy = typeof mappedByOrOptions === 'object' ? mappedByOrOptions.mappedBy : mappedByOrOptions;
  options = typeof mappedByOrOptions === 'object' ? { ...mappedByOrOptions, ...options } : options;
  return function (_, context) {
    const meta = prepareMetadataContext(context, ReferenceKind.ONE_TO_ONE);
    options = processDecoratorParameters({ entity, mappedBy, options });
    const property = { name: context.name, kind: ReferenceKind.ONE_TO_ONE };
    meta.properties[context.name] = Object.assign(meta.properties[context.name] ?? {}, property, options);
  };
}
