{"version":3,"file":"getOwnPropertyDescriptors.mjs","names":[],"sources":["../../../src/utils/reflection/getOwnPropertyDescriptors.ts"],"sourcesContent":["import type { InstanceOrStatic } from '../miscTypes.ts';\nimport type { BaseClassProto as BaseClassPrototype, ClassLike, ConstructorConstraint, SuperClassLike, WithProto as WithPrototype } from './inheritance.ts';\nimport type { InstancePropertyDescriptorMap } from './InstancePropertyDescriptorMap.d.ts';\nimport type { OwnPropertyDescriptorMap } from './OwnPropertyDescriptorMap.d.ts';\n\n/**\n * Get the property descriptors of the class or constructor similar to {@link Object.getOwnPropertyDescriptors}, but with more options--including recursion.\n * @template {InstanceOrStatic} _InstanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @param classDefinition A class or constructor, cast to {@link ClassLike}.\n * @param instanceOrStatic 'Instance' or 'Static'. Determines the return type.\n * @template {ClassLike<ConstructorConstraint<Class> & WithProto<SuperClassLike | BaseClassProto>>} Class\n * The typeof {@link classDefinition}.\n * {@link WithProto}<{@link SuperClassLike}> is necessary for walking the\n * prototype chain for both Instance  and Static properties.\n * If unspecified, the return type may be incorrect.\n * @returns ({@link instanceOrStatic} === 'Instance') ? {@link InstancePropertyDescriptorMap<Class>}\\\n * : ({@link instanceOrStatic} === 'Static') ? {@link OwnPropertyDescriptorMap<Class>}\\\n * : never\n * @throws {TypeError}\n * @since 3.0.0\n */\nexport function getOwnPropertyDescriptors<\n  Class extends ClassLike<ConstructorConstraint<Class> & WithPrototype<SuperClassLike | BaseClassPrototype>>,\n  _InstanceOrStatic extends InstanceOrStatic,\n>(\n  classDefinition: Class,\n  instanceOrStatic: _InstanceOrStatic,\n): [_InstanceOrStatic] extends ['Instance']\n  ? InstancePropertyDescriptorMap<Class>\n  : [_InstanceOrStatic] extends ['Static']\n      ? OwnPropertyDescriptorMap<Class>\n      : never {\n  switch (instanceOrStatic) {\n    case 'Instance': {\n      return Object.getOwnPropertyDescriptors(classDefinition.prototype) as [Extract<typeof instanceOrStatic, 'Instance'>] extends ['Instance']\n        ? InstancePropertyDescriptorMap<Class>\n        : [_InstanceOrStatic] extends ['Static']\n            ? OwnPropertyDescriptorMap<Class>\n            : never;\n    }\n    case 'Static': {\n      return Object.getOwnPropertyDescriptors(classDefinition) as [Extract<typeof instanceOrStatic, 'Static'>] extends ['Instance']\n        ? InstancePropertyDescriptorMap<Class>\n        : [_InstanceOrStatic] extends ['Static']\n            ? OwnPropertyDescriptorMap<Class>\n            : never;\n    }\n    default: {\n      throw new TypeError('Argument `instanceOrStatic` must be \"Instance\" or \"Static\".');\n    }\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAqBA,SAAgB,0BAId,iBACA,kBAKY;CACZ,QAAQ,kBAAR;EACE,KAAK,YACH,OAAO,OAAO,0BAA0B,gBAAgB,SAAS;EAMnE,KAAK,UACH,OAAO,OAAO,0BAA0B,eAAe;EAMzD,SACE,MAAM,IAAI,UAAU,iEAA6D;CAErF;AACF"}