{"version":3,"file":"components.mjs","sources":["../../src/registries/components.ts"],"sourcesContent":["import { has } from 'lodash/fp';\nimport type { Struct, UID } from '@strapi/types';\n\nconst componentsRegistry = () => {\n  const components: Record<UID.Component, Struct.ComponentSchema> = {};\n\n  return {\n    /**\n     * Returns this list of registered components uids\n     */\n    keys(): UID.Component[] {\n      return Object.keys(components) as UID.Component[];\n    },\n\n    /**\n     * Returns the instance of a component. Instantiate the component if not already done\n     */\n    get(uid: UID.Component) {\n      return components[uid];\n    },\n\n    /**\n     * Returns a map with all the components in a namespace\n     */\n    getAll() {\n      return components;\n    },\n\n    /**\n     * Registers a component\n     */\n    set(uid: UID.Component, component: Struct.ComponentSchema) {\n      if (has(uid, components)) {\n        throw new Error(`Component ${uid} has already been registered.`);\n      }\n\n      components[uid] = component;\n\n      return this;\n    },\n\n    /**\n     * Registers a map of components for a specific namespace\n     */\n    add(newComponents: Record<UID.Component, Struct.ComponentSchema>) {\n      for (const uid of Object.keys(newComponents) as UID.Component[]) {\n        this.set(uid, newComponents[uid]);\n      }\n    },\n  };\n};\n\nexport default componentsRegistry;\n"],"names":["componentsRegistry","components","keys","Object","get","uid","getAll","set","component","has","Error","add","newComponents"],"mappings":";;AAGA,MAAMA,kBAAAA,GAAqB,IAAA;AACzB,IAAA,MAAMC,aAA4D,EAAC;IAEnE,OAAO;AACL;;QAGAC,IAAAA,CAAAA,GAAAA;YACE,OAAOC,MAAAA,CAAOD,IAAI,CAACD,UAAAA,CAAAA;AACrB,QAAA,CAAA;AAEA;;AAEC,QACDG,KAAIC,GAAkB,EAAA;YACpB,OAAOJ,UAAU,CAACI,GAAAA,CAAI;AACxB,QAAA,CAAA;AAEA;;QAGAC,MAAAA,CAAAA,GAAAA;YACE,OAAOL,UAAAA;AACT,QAAA,CAAA;AAEA;;QAGAM,GAAAA,CAAAA,CAAIF,GAAkB,EAAEG,SAAiC,EAAA;YACvD,IAAIC,GAAAA,CAAIJ,KAAKJ,UAAAA,CAAAA,EAAa;AACxB,gBAAA,MAAM,IAAIS,KAAAA,CAAM,CAAC,UAAU,EAAEL,GAAAA,CAAI,6BAA6B,CAAC,CAAA;AACjE,YAAA;YAEAJ,UAAU,CAACI,IAAI,GAAGG,SAAAA;AAElB,YAAA,OAAO,IAAI;AACb,QAAA,CAAA;AAEA;;AAEC,QACDG,KAAIC,aAA4D,EAAA;AAC9D,YAAA,KAAK,MAAMP,GAAAA,IAAOF,MAAAA,CAAOD,IAAI,CAACU,aAAAA,CAAAA,CAAmC;AAC/D,gBAAA,IAAI,CAACL,GAAG,CAACF,GAAAA,EAAKO,aAAa,CAACP,GAAAA,CAAI,CAAA;AAClC,YAAA;AACF,QAAA;AACF,KAAA;AACF;;;;"}