import { ReferenceKind, Utils } from '@mikro-orm/core';
import { prepareMetadataContext } from '../utils.js';
/** Defines an embedded property on an entity (TC39 decorator). */
export function Embedded(type = {}, options = {}) {
  return function (value, context) {
    const meta = prepareMetadataContext(context, ReferenceKind.EMBEDDED);
    options = type instanceof Function ? { entity: type, ...options } : { ...type, ...options };
    Utils.defaultValue(options, 'prefix', true);
    meta.properties[context.name] = {
      name: context.name,
      kind: ReferenceKind.EMBEDDED,
      ...options,
    };
  };
}
