{"version":3,"sources":["../src/lib/is-type-provider.ts","../src/lib/load-module.ts","../src/lib/resolve-component.ts","../src/lib/resolve-provider.ts","../src/lib/resolve-providers.ts","../src/lib/resolve-dependencies.ts","../src/lib/fast.ts","../src/lib/fast-bootstrap-application.ts"],"names":["isTypeProvider","value","loadModule","module","result","resolveComponent","component","resolveProvider","provider","loadedProvider","resolveProviders","providers","resolveDependencies","resolvedComponent","resolvedProviders","fast","bootstrap","rootComponent","options","nextOptions","fastBootstrapApplication","bootstrapApplication"],"mappings":"6DAIaA,IAAAA,CAAAA,CAAkBC,GACzB,OAAOA,CAAAA,EAAU,YAIjB,CAACA,CAAAA,CAAM,SACF,CAAA,CAAA,CAAA,CAGFA,CAAM,CAAA,SAAA,CAAU,cAAgBA,ECXlC,IAAMC,EAAa,MAAUC,CAAAA,EAAsC,CAExE,IAAMC,CAAAA,CAAU,MAAMD,CAAAA,EACtB,CAAA,OAAIC,EAAO,OACFA,CAAAA,CAAAA,CAAO,QAGTA,CACT,ECJO,IAAMC,CAAmB,CAAA,MAC9BC,CAEIN,EAAAA,CAAAA,CAAeM,CAAS,CAAA,CACnBA,EAGc,MAAMJ,CAAAA,CAAWI,CAAS,CCT5C,CAAA,IAAMC,EAAkB,MAC7BC,CAAAA,EACoC,CACpC,GAAI,KAAM,CAAA,OAAA,CAAQA,CAAQ,CACxB,CAAA,OAAOA,EAGT,GAAI,OAAOA,GAAa,UACtB,CAAA,OAAO,CAACA,CAAQ,CAGlB,CAAA,GAAIR,EAAeQ,CAAQ,CAAA,CACzB,OAAO,CAACA,CAAQ,EAGlB,IAAIC,CAAAA,CAAiB,MAAMP,CAAAA,CAAWM,CAAQ,CAAA,CAE9C,OAAK,KAAM,CAAA,OAAA,CAAQC,CAAc,CAC/BA,GAAAA,CAAAA,CAAiB,CAACA,CAAc,CAAA,CAAA,CAG3BA,CACT,ECvBaC,IAAAA,CAAAA,CAAmB,MAC9BC,CAE0D,EAAA,CAAA,MAAM,QAAQ,GACtEA,CAAAA,CAAAA,CAAU,IAAIJ,CAAe,CAC/B,CAE0B,EAAA,IAAA,GCJrB,IAAMK,EAAsB,MACjCN,CAAAA,CACAK,IAC6E,CAC7E,GAAM,CAACE,CAAmBC,CAAAA,CAAiB,CAAI,CAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,CAC/DT,CAAiBC,CAAAA,CAAS,EAC1BI,CAAiBC,CAAAA,CAAS,CAC5B,CAAC,CAAA,CACD,OAAO,CAAE,SAAWE,CAAAA,CAAAA,CAAmB,UAAWC,CAAkB,CACtE,ECyBaC,IAAAA,CAAAA,CAAO,MAClBC,CACAC,CAAAA,CAAAA,CACAC,CAC4B,GAAA,CAC5B,GAAM,CAAE,UAAAZ,CAAW,CAAA,SAAA,CAAAK,CAAU,CAAI,CAAA,MAAMC,EACrCK,CACAC,CAAAA,CAAAA,EAAS,SAAa,EAAA,EACxB,CAAA,CACMC,EAAiC,CACrC,GAAGD,EACH,SAAAP,CAAAA,CACF,EAEA,OAAOK,CAAAA,CAAUV,CAAWa,CAAAA,CAAW,CACzC,EChBaC,IAAAA,CAAAA,CAA2B,MACtCH,CACAC,CAAAA,CAAAA,GAC4B,CAC5B,GAAM,CAAE,SAAA,CAAAZ,EAAW,SAAAK,CAAAA,CAAU,EAAI,MAAMC,CAAAA,CACrCK,EACAC,CAAS,EAAA,SAAA,EAAa,EACxB,CACMC,CAAAA,CAAAA,CAAiC,CACrC,GAAGD,CAAAA,CACH,UAAAP,CACF,CAAA,CAEA,OAAOI,CAAKM,CAAAA,oBAAAA,CAAsBf,CAAWa,CAAAA,CAAW,CAC1D","file":"index.mjs","sourcesContent":["import { TypeProvider } from '@angular/core';\n\nimport { FastProvider } from './types';\n\nexport const isTypeProvider = (value: FastProvider): value is TypeProvider => {\n  if (typeof value !== 'function') {\n    return false;\n  }\n\n  if (!value.prototype) {\n    return false;\n  }\n\n  return value.prototype.constructor === value;\n};\n","import { LazyModule } from './types';\n\nexport const loadModule = async <T>(module: LazyModule<T>): Promise<T> => {\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  const result = (await module()) as any;\n  if (result['default']) {\n    return result.default;\n  }\n\n  return result;\n};\n","import { Type } from '@angular/core';\n\nimport { isTypeProvider } from './is-type-provider';\nimport { loadModule } from './load-module';\nimport { FastComponent } from './types';\n\nexport const resolveComponent = async (\n  component: FastComponent,\n): Promise<Type<unknown>> => {\n  if (isTypeProvider(component)) {\n    return component;\n  }\n\n  const loadedProvider = await loadModule(component);\n\n  return loadedProvider;\n};\n","import { isTypeProvider } from './is-type-provider';\nimport { loadModule } from './load-module';\nimport { AngularProvider, FastProvider } from './types';\n\nexport const resolveProvider = async (\n  provider: FastProvider,\n): Promise<Array<AngularProvider>> => {\n  if (Array.isArray(provider)) {\n    return provider;\n  }\n\n  if (typeof provider !== 'function') {\n    return [provider];\n  }\n\n  if (isTypeProvider(provider)) {\n    return [provider];\n  }\n\n  let loadedProvider = await loadModule(provider);\n\n  if (!Array.isArray(loadedProvider)) {\n    loadedProvider = [loadedProvider];\n  }\n\n  return loadedProvider;\n};\n","import { resolveProvider } from './resolve-provider';\nimport { AngularProvider, FastProvider } from './types';\n\nexport const resolveProviders = async (\n  providers: Array<FastProvider>,\n): Promise<Array<AngularProvider>> => {\n  const unflattedProviders: Array<Array<AngularProvider>> = await Promise.all(\n    providers.map(resolveProvider),\n  );\n\n  return unflattedProviders.flat();\n};\n","import { Type } from '@angular/core';\n\nimport { resolveComponent } from './resolve-component';\nimport { resolveProviders } from './resolve-providers';\nimport { AngularProvider, FastComponent, FastProvider } from './types';\n\nexport const resolveDependencies = async (\n  component: FastComponent,\n  providers: Array<FastProvider>,\n): Promise<{ component: Type<unknown>; providers: Array<AngularProvider> }> => {\n  const [resolvedComponent, resolvedProviders] = await Promise.all([\n    resolveComponent(component),\n    resolveProviders(providers),\n  ]);\n  return { component: resolvedComponent, providers: resolvedProviders };\n};\n","import { ApplicationConfig, ApplicationRef } from '@angular/core';\nimport type { bootstrapApplication } from '@angular/platform-browser';\n\nimport { resolveDependencies } from './resolve-dependencies';\nimport { FastApplicationConfig, FastComponent } from './types';\n\n/**\n * Dynamically loads the specified providers in the configuration and bootstraps an Angular application.\n *\n * This function uses the custom applicationBoostrap function argument to start an Angular application with providers\n * that are dynamically loaded and resolved. The application configuration can include providers that need to\n * be loaded asynchronously. This function handles resolving these providers and passing them to the custom bootstrap function.\n *\n * @param bootstrap - The Angular application's bootstrap function (typically `bootstrapApplication`).\n * @param rootComponent - The root component of the application, which should be of type `FastComponent`\n *                  (ie. Type<unknown> or lazy module that return this component).\n * @param options - (Optional) The application configuration, including the providers to be loaded. It should conform\n *                  to the `FastApplicationConfig` type. Providers can be `Provider`, `EnvironmentProviders`,\n *                  or lazy modules that return these providers.\n *\n * @returns A Promise that resolves to an `ApplicationRef` instance of the bootstrapped application. The bootstrap\n *          method is called with the root component and the updated configuration with the resolved providers.\n *\n * @example\n * ```typescript\n * import { AppComponent } from './app.component';\n * import { bootstrapApplication } from '@angular/platform-browser';\n * import { fast } from 'ngx-fastboot';\n *\n * fast(bootstrapApplication, AppComponent, {\n *   providers: [\n *     MyProvider,\n *     () => import('./my-provider.module'),\n *   ]\n * }).then(() => console.log('App is bootstrapped'))\n *   .catch(error => {\n *     console.error('Error bootstrapping the app', error);\n *   });\n * ```\n */\nexport const fast = async (\n  bootstrap: typeof bootstrapApplication,\n  rootComponent: FastComponent,\n  options?: FastApplicationConfig,\n): Promise<ApplicationRef> => {\n  const { component, providers } = await resolveDependencies(\n    rootComponent,\n    options?.providers ?? [],\n  );\n  const nextOptions: ApplicationConfig = {\n    ...options,\n    providers,\n  };\n\n  return bootstrap(component, nextOptions);\n};\n","import { ApplicationConfig, ApplicationRef } from '@angular/core';\nimport { bootstrapApplication } from '@angular/platform-browser';\n\nimport { fast } from './fast';\nimport { resolveDependencies } from './resolve-dependencies';\nimport { FastApplicationConfig, FastComponent } from './types';\n\n/**\n * Dynamically loads the specified providers in the configuration and bootstraps an Angular application.\n *\n * This function start an Angular application with providers that are dynamically loaded and resolved.\n * The application configuration can include providers that need to be loaded asynchronously.\n * This function handles resolving these providers and passing them to the angular bootstrapApplication function.\n *\n * @param rootComponent - The root component of the application, which should be of type `FastComponent`\n *                  (ie. Type<unknown> or lazy module that return this component).\n * @param options - (Optional) The application configuration, including the providers to be loaded. It should conform\n *                  to the `FastApplicationConfig` type. Providers can be `Provider`, `EnvironmentProviders`,\n *                  or lazy modules that return these providers.\n *\n * @returns A Promise that resolves to an `ApplicationRef` instance of the bootstrapped application. The bootstrap\n *          method is called with the root component and the updated configuration with the resolved providers.\n *\n * @example\n * ```typescript\n * import { AppComponent } from './app.component';\n * import { fastBootstrapApplication } from 'ngx-fastboot';\n *\n * fastBootstrapApplication(AppComponent, {\n *   providers: [\n *     MyProvider,\n *     () => import('./my-provider.module'),\n *   ]\n * }).then(() => console.log('App is bootstrapped'))\n *   .catch(error => {\n *     console.error('Error bootstrapping the app', error);\n *   });\n * ```\n */\nexport const fastBootstrapApplication = async (\n  rootComponent: FastComponent,\n  options?: FastApplicationConfig,\n): Promise<ApplicationRef> => {\n  const { component, providers } = await resolveDependencies(\n    rootComponent,\n    options?.providers ?? [],\n  );\n  const nextOptions: ApplicationConfig = {\n    ...options,\n    providers,\n  };\n\n  return fast(bootstrapApplication, component, nextOptions);\n};\n"]}