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