{
  "version": 3,
  "sources": ["../../src/utils/ComponentFactory.ts"],
  "sourcesContent": ["import { UITagsEnum } from 'constants/UITags.enum';\nimport { safeWindow } from 'constants/window.constants';\nimport type { IEventBus } from 'lib/sdkDappUi';\n\nexport interface CreateEventBusUIElementType extends HTMLElement {\n  getEventBus: () => Promise<IEventBus | null>;\n}\n\nexport type CreateComponentType = <T = CreateEventBusUIElementType>({\n  name,\n  anchor\n}: {\n  name: `${UITagsEnum}`;\n  anchor?: HTMLElement;\n}) => Promise<T>;\n\nexport class ComponentFactory {\n  private static createComponent: CreateComponentType = async <\n    T = CreateEventBusUIElementType\n  >({\n    name,\n    anchor\n  }: {\n    name: `${UITagsEnum}`;\n    anchor?: HTMLElement;\n  }) => {\n    const webComponent = safeWindow?.customElements?.get(name);\n\n    if (!webComponent) {\n      return null as T;\n    }\n\n    const element = safeWindow.document.createElement(name);\n    const rootElement = anchor || safeWindow.document.body;\n    rootElement.appendChild(element);\n    await customElements.whenDefined(name);\n\n    return element as T;\n  };\n\n  static get create() {\n    return this.createComponent;\n  }\n\n  static set create(customCreateFunction: CreateComponentType) {\n    this.createComponent = customCreateFunction;\n  }\n}\n"],
  "mappings": "yCAgBO,IAAMA,EAAN,KAAuB,CAwB5B,WAAW,QAAS,CAClB,OAAO,KAAK,eACd,CAEA,WAAW,OAAOC,EAA2C,CAC3D,KAAK,gBAAkBA,CACzB,CACF,EA/BaD,EACI,gBAAuC,MAEpD,CACA,KAAAE,EACA,OAAAC,CACF,IAGM,CAGJ,GAAI,CAFiBC,GAAY,gBAAgB,IAAIF,CAAI,EAGvD,OAAO,KAGT,IAAMG,EAAUD,EAAW,SAAS,cAAcF,CAAI,EAEtD,OADoBC,GAAUC,EAAW,SAAS,MACtC,YAAYC,CAAO,EAC/B,MAAM,eAAe,YAAYH,CAAI,EAE9BG,CACT",
  "names": ["ComponentFactory", "customCreateFunction", "name", "anchor", "safeWindow", "element"]
}
