{"version":3,"file":"fundamental-ngx-ui5-webcomponents-base-theming.mjs","sources":["../../../../libs/ui5-webcomponents-base/theming/ui5-theming.models.ts","../../../../libs/ui5-webcomponents-base/theming/ui5-theming-api.ts","../../../../libs/ui5-webcomponents-base/theming/supported-themes.ts","../../../../libs/ui5-webcomponents-base/theming/base-webcomponents-theming-provider.ts","../../../../libs/ui5-webcomponents-base/theming/theming-api.ts","../../../../libs/ui5-webcomponents-base/theming/fundamental-ngx-ui5-webcomponents-base-theming.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport interface ThemingConfig {\n  defaultTheme: string;\n}\n\nexport const UI5_THEMING_CONFIGURATION = new InjectionToken<ThemingConfig>(\n  'Ui5 global theming configuration.'\n);\n\nexport interface Ui5ThemingProvider {\n  name: string;\n  getAvailableThemes(): string[] | Promise<string[]>;\n  supportsTheme(themeName: string): boolean | Promise<boolean>;\n  setTheme(themeName: string): Promise<boolean>;\n}\n\nexport interface Ui5ThemingConsumer extends Omit<Ui5ThemingProvider, 'name'> {\n  registerProvider(provider: Ui5ThemingProvider): void;\n  unregisterProvider(provider: Ui5ThemingProvider): void;\n}\n","// ui5-theming.service.ts\nimport { inject, Injectable, isDevMode, signal, computed, effect } from '@angular/core';\nimport {\n  UI5_THEMING_CONFIGURATION,\n  Ui5ThemingProvider,\n  Ui5ThemingConsumer,\n} from './ui5-theming.models';\n\n@Injectable({\n  providedIn: 'root'\n})\nexport class Ui5ThemingService implements Ui5ThemingConsumer {\n\n  readonly availableThemes = computed<string[]>(() => {\n    const providers = this._providers();\n    const uniqueThemes = new Set<string>();\n    \n    // Using a normal loop to handle synchronous and asynchronous results\n    for (const provider of providers) {\n      const themes = provider.getAvailableThemes();\n      if (Array.isArray(themes)) {\n        themes.forEach(theme => uniqueThemes.add(theme));\n      } else {\n        // TODO Since providers now return a promise, we'd need to handle this asynchronously\n        // For simplicity, we'll assume a `Promise` is returned and handle it inside the effect\n      }\n    }\n    return [...uniqueThemes.values()];\n  });\n\n  private readonly _config = inject(UI5_THEMING_CONFIGURATION, { optional: true });\n  private readonly _providers = signal<Ui5ThemingProvider[]>([]);\n\n  private readonly _currentTheme = signal(this._config?.defaultTheme || 'sap_fiori_3');\n\n  constructor() {\n    effect(async () => {\n      const newTheme = this._currentTheme();\n      const providers = this._providers();\n\n      if (providers.length === 0) {\n        return;\n      }\n\n      const results = await Promise.all(\n        providers.map(async (provider) => {\n          const isSupported = await provider.supportsTheme(newTheme);\n          return { provider, isSupported };\n        })\n      );\n\n      const unsupportedProviders = results.filter(r => !r.isSupported);\n      if (unsupportedProviders.length > 0 && isDevMode()) {\n        console.warn(\n          `The following providers do not support the theme \"${newTheme}\":`,\n          unsupportedProviders.map(({ provider }) => provider.name)\n        );\n      }\n\n      await Promise.all(\n        results.filter(r => r.isSupported).map(({ provider }) =>\n          provider.setTheme(newTheme)\n        )\n      );\n    });\n  }\n\n\n  getAvailableThemes(): string[] {\n    return this.availableThemes();\n  }\n\n  supportsTheme(themeName: string): Promise<boolean> {\n    return Promise.resolve(this.availableThemes().includes(themeName));\n  }\n\n  registerProvider(provider: Ui5ThemingProvider): void {\n    const providers = this._providers();\n    if (!providers.includes(provider)) {\n      this._providers.update(currentProviders => [...currentProviders, provider]);\n    }\n  }\n\n  unregisterProvider(provider: Ui5ThemingProvider): void {\n    this._providers.update(currentProviders =>\n      currentProviders.filter(p => p !== provider)\n    );\n  }\n\n  setTheme(theme: string): Promise<boolean> {\n    this._currentTheme.set(theme);\n    return Promise.resolve(true);\n  }\n}\n","export default [\n    'sap_fiori_3',\n    'sap_fiori_3_dark',\n    'sap_fiori_3_hcb',\n    'sap_fiori_3_hcw',\n    'sap_horizon',\n    'sap_horizon_dark',\n    'sap_horizon_hcb',\n    'sap_horizon_hcw'\n];\n","/**\n * @file Defines the abstract base class for theming providers in Angular,\n * designed to integrate with UI5 Web Components' theme management.\n *\n * This provider registers itself with a global theming service (if available) and\n * manages a list of supported themes, allowing other parts of the application\n * to query theme support and apply themes to the underlying UI5 Web Components.\n */\n\n// base-webcomponents-theming-provider.ts\nimport { inject, Injectable, OnDestroy, signal } from \"@angular/core\";\nimport { Ui5ThemingService } from \"./ui5-theming-api\";\nimport { Ui5ThemingProvider } from \"./ui5-theming.models\";\nimport supportedThemes from './supported-themes';\nimport { setTheme } from '@ui5/webcomponents-base/dist/config/Theme.js';\n\n/**\n * @description\n * Abstract base class for UI5 Web Components theming providers.\n *\n * Components extending this class are responsible for providing the necessary theme resources\n * (via the `registerThemes` callback) and exposing the supported themes. It integrates\n * with the global {@link Ui5ThemingService} to make its themes available application-wide.\n *\n * @implements {Ui5ThemingProvider}\n * @implements {OnDestroy}\n */\n@Injectable()\nexport abstract class WebcomponentsThemingProvider implements Ui5ThemingProvider, OnDestroy {\n  /**\n   * @description\n   * The unique name for this theming provider, which must be implemented by subclasses.\n   * This is used by the global {@link Ui5ThemingService} for registration and identification.\n   */\n  abstract name: string;\n\n  /**\n   * @description\n   * A signal containing the list of themes supported by this provider.\n   * It is initialized with the themes loaded from the `supported-themes` file.\n   */\n  protected availableThemes = signal<string[]>(supportedThemes);\n  \n  /**\n   * @description\n   * Reference to the global {@link Ui5ThemingService}, injected optionally.\n   * The provider registers itself here if the global service is available.\n   */\n  protected _globalThemingService: Ui5ThemingService | null = inject(Ui5ThemingService, { optional: true });\n\n  /** @hidden */\n  protected constructor(\n    protected registerThemes: () => Promise<any>\n  ) {\n    this.registerThemes().then(() => {\n      this._globalThemingService?.registerProvider(this);\n    });\n  }\n\n  /** @hidden */\n  ngOnDestroy(): void {\n    this._globalThemingService?.unregisterProvider(this);\n  }\n\n  /**\n   * @description\n   * Checks if a specific theme name is supported by this provider.\n   * @param theme The name of the theme to check (e.g., 'sap_horizon').\n   * @returns `true` if the theme is supported, `false` otherwise.\n   */\n  supportsTheme(theme: string): boolean | Promise<boolean> {\n    return this.availableThemes().includes(theme);\n  }\n\n  /**\n   * @description\n   * Retrieves the list of theme names supported by this provider.\n   * @returns An array of supported theme names.\n   */\n  getAvailableThemes(): string[] | Promise<string[]> {\n    return this.availableThemes();\n  }\n\n  /**\n   * @description\n   * Attempts to set the given theme globally for all UI5 Web Components.\n   *\n   * The theme is only applied if it is included in the list of available themes\n   * managed by this provider.\n   *\n   * @param theme The name of the theme to apply.\n   * @returns A promise that resolves to `true` if the theme was applied, or `false` if the theme is not supported.\n   */\n  async setTheme(theme: string): Promise<boolean> {\n    const supported = this.availableThemes().includes(theme);\n    if (supported) {\n      setTheme(theme);\n    }\n    return supported;\n  }\n}\n","import { Injectable } from \"@angular/core\";\nimport { WebcomponentsThemingProvider } from \"./base-webcomponents-theming-provider\";\n\n/**\n * Theming service specifically for the ui5/webcomponents-ngx components.\n */\n@Injectable({\n  providedIn: 'root'\n})\nexport class Ui5WebcomponentsThemingService extends WebcomponentsThemingProvider {\n  name = 'ui5-webcomponents-theming-service';\n\n  /** @hidden */\n  constructor() {\n    super(() => import('@ui5/webcomponents-theming/dist/generated/json-imports/Themes.js'));\n  }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;MAMa,yBAAyB,GAAG,IAAI,cAAc,CACzD,mCAAmC;;ACPrC;MAWa,iBAAiB,CAAA;AAwB5B,IAAA,WAAA,GAAA;AAtBS,QAAA,IAAA,CAAA,eAAe,GAAG,QAAQ,CAAW,MAAK;AACjD,YAAA,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE;AACnC,YAAA,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU;;AAGtC,YAAA,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE;AAChC,gBAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,kBAAkB,EAAE;AAC5C,gBAAA,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;AACzB,oBAAA,MAAM,CAAC,OAAO,CAAC,KAAK,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAClD;qBAAO;;;gBAGP;YACF;AACA,YA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