{"version":3,"file":"dfx-theme.mjs","sources":["../../../libs/dfx-theme/src/lib/system-theme-manager.ts","../../../libs/dfx-theme/src/lib/theme-dom.ts","../../../libs/dfx-theme/src/lib/theme-strategies.ts","../../../libs/dfx-theme/src/lib/theme.config.ts","../../../libs/dfx-theme/src/lib/theme.service.ts","../../../libs/dfx-theme/src/lib/theme.feature.ts","../../../libs/dfx-theme/src/lib/theme.storage.ts","../../../libs/dfx-theme/src/lib/theme.provider.ts","../../../libs/dfx-theme/src/public-api.ts","../../../libs/dfx-theme/src/dfx-theme.ts"],"sourcesContent":["import { ThemeConfig } from './theme.types';\n\nexport class SystemThemeManager {\n  mediaQuery: MediaQueryList | null = null;\n  private isDestroyed = false;\n\n  setup(config: ThemeConfig): void {\n    try {\n      if (typeof window !== 'undefined' && window.matchMedia && config.enableSystem && !this.isDestroyed) {\n        this.mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n        this.updateSystemTheme();\n      }\n    } catch (error) {\n      console.warn('Failed to setup media query for system theme detection:', error);\n    }\n  }\n\n  updateSystemTheme(): 'light' | 'dark' {\n    try {\n      if (this.mediaQuery && !this.isDestroyed) {\n        return this.mediaQuery.matches ? 'dark' : 'light';\n      }\n      return 'light';\n    } catch (error) {\n      console.warn('Failed to update system theme:', error);\n      return 'light';\n    }\n  }\n\n  addChangeListener(callback: () => void): void {\n    if (this.mediaQuery && !this.isDestroyed) {\n      this.mediaQuery.addEventListener('change', callback);\n    }\n  }\n\n  removeChangeListener(callback: () => void): void {\n    if (this.mediaQuery) {\n      this.mediaQuery.removeEventListener('change', callback);\n    }\n  }\n\n  cleanup(): void {\n    this.isDestroyed = true;\n    this.mediaQuery = null;\n  }\n}\n","import { ResolvedTheme, ThemeStrategy } from './theme.types';\n\nexport function applyTheme(theme: ResolvedTheme, strategies: ThemeStrategy[]): void {\n  try {\n    const element = document.documentElement;\n\n    for (const strategy of strategies) {\n      strategy(element, theme);\n    }\n  } catch (error) {\n    console.error('Failed to apply theme:', error);\n  }\n}\n","import { ResolvedTheme, ThemeStrategy } from './theme.types';\n\nexport const themeClassStrategy: ThemeStrategy = (element: HTMLElement, theme: ResolvedTheme) => {\n  try {\n    if (theme === 'dark') {\n      element.classList.add('dark');\n    } else {\n      element.classList.remove('dark');\n    }\n  } catch (error) {\n    console.warn('Failed to apply class theme:', error);\n  }\n};\n\nexport const themeAttributeStrategy: ThemeStrategy = (element: HTMLElement, theme: ResolvedTheme) => {\n  try {\n    if (theme === 'dark') {\n      element.setAttribute('data-theme', 'dark');\n    } else {\n      element.setAttribute('data-theme', 'light');\n    }\n  } catch (error) {\n    console.warn('Failed to apply attribute theme:', error);\n  }\n};\n\nexport const themeColorSchemeStrategy: ThemeStrategy = (element: HTMLElement, theme: ResolvedTheme) => {\n  try {\n    element.style.colorScheme = theme;\n  } catch (error) {\n    console.warn('Failed to apply color scheme:', error);\n  }\n};\n","import { InjectionToken } from '@angular/core';\n\nimport { themeClassStrategy, themeColorSchemeStrategy } from './theme-strategies';\nimport { ThemeConfig, ThemeStorageManager, ThemeStrategy } from './theme.types';\n\nexport const DEFAULT_THEME_CONFIG: ThemeConfig = {\n  defaultTheme: 'system',\n  enableAutoInit: true,\n  enableSystem: true,\n};\n\nexport const THEME_CONFIG = new InjectionToken<ThemeConfig>('THEME_CONFIG', {\n  factory: () => DEFAULT_THEME_CONFIG,\n});\n\nexport const THEME_STORAGE_KEY = new InjectionToken('THEME_STORAGE_KEY', {\n  factory: () => 'theme',\n});\n\nexport const THEME_STORAGE_MANAGER = new InjectionToken<ThemeStorageManager>('THEME_STORAGE_KEY');\n\nexport const THEME_STRATEGIES = new InjectionToken<ThemeStrategy[]>('THEME_STRATEGIES', {\n  factory: () => [themeColorSchemeStrategy, themeClassStrategy],\n});\n","import { isPlatformBrowser } from '@angular/common';\nimport { Injectable, Injector, OnDestroy, PLATFORM_ID, computed, effect, inject, signal } from '@angular/core';\n\nimport { SystemThemeManager } from './system-theme-manager';\nimport { applyTheme } from './theme-dom';\nimport { THEME_CONFIG, THEME_STORAGE_KEY, THEME_STORAGE_MANAGER, THEME_STRATEGIES } from './theme.config';\nimport { Theme } from './theme.types';\n\n@Injectable({\n  providedIn: 'root',\n})\nexport class ThemeService implements OnDestroy {\n  private readonly platformId = inject(PLATFORM_ID);\n  private readonly injector = inject(Injector);\n  private readonly config = inject(THEME_CONFIG);\n  private readonly themeStrategies = inject(THEME_STRATEGIES);\n\n  private readonly storageKey = inject(THEME_STORAGE_KEY);\n  private readonly storageManager = inject(THEME_STORAGE_MANAGER, { optional: true });\n\n  // Managers\n  private readonly mediaManager = new SystemThemeManager();\n  private readonly systemThemeChangeListener = this.handleSystemThemeChange.bind(this);\n\n  // Private state\n  private isInitialized = false;\n  private isDestroyed = false;\n  private lastAppliedTheme: 'light' | 'dark' | null = null;\n\n  // Signals\n  private readonly themeSignal = signal<Theme>(this.config.defaultTheme);\n  private readonly systemThemeSignal = signal<'light' | 'dark'>('light');\n\n  // Public readonly signals\n  readonly theme = this.themeSignal.asReadonly();\n  readonly systemTheme = this.systemThemeSignal.asReadonly();\n  readonly resolvedTheme = computed(() => {\n    if (this.config.forcedTheme && this.config.forcedTheme !== 'system') {\n      return this.config.forcedTheme;\n    }\n\n    const theme = this.themeSignal();\n    if (theme === 'system') {\n      if (isPlatformBrowser(this.platformId) && this.config.enableSystem) {\n        return this.systemThemeSignal();\n      }\n\n      return 'light';\n    }\n\n    return theme;\n  });\n\n  // Getters\n  get initialized(): boolean {\n    return this.isInitialized;\n  }\n\n  get isForced(): boolean {\n    return !!this.config.forcedTheme;\n  }\n\n  // Public methods\n  initialize(): void {\n    if (this.isInitialized || this.isDestroyed) {\n      console.warn(this.isDestroyed ? 'ThemeService has been destroyed' : 'ThemeService is already initialized');\n      return;\n    }\n\n    try {\n      if (isPlatformBrowser(this.platformId)) {\n        this.setupManagers();\n        this.loadInitialTheme();\n        this.setupEffects();\n      } else {\n        // SSR fallback - just set default values without DOM access\n        this.themeSignal.set(this.config.defaultTheme);\n        this.systemThemeSignal.set('light');\n      }\n\n      this.isInitialized = true;\n    } catch (error) {\n      console.error('Failed to initialize ThemeService:', error);\n      this.setFallbackThemes();\n    }\n  }\n\n  setTheme(theme: Theme): void {\n    if (this.isDestroyed) {\n      console.warn('ThemeService has been destroyed');\n      return;\n    }\n\n    if (this.config.forcedTheme) {\n      console.warn('Theme cannot be changed while forced theme is active');\n      return;\n    }\n\n    const validThemes = ['light', 'dark', ...(this.config.enableSystem ? ['system'] : [])];\n    if (!validThemes.includes(theme)) {\n      console.warn(`Theme \"${theme}\" is not supported. Available themes: ${validThemes.join(', ')}`);\n      return;\n    }\n\n    this.themeSignal.set(theme);\n  }\n\n  toggle(): void {\n    if (this.isDestroyed || this.config.forcedTheme) {\n      console.warn(this.isDestroyed ? 'ThemeService has been destroyed' : 'Theme cannot be toggled while forced theme is active');\n      return;\n    }\n\n    try {\n      const currentTheme = this.themeSignal();\n      const themes: Theme[] = this.config.enableSystem ? ['light', 'dark', 'system'] : ['light', 'dark'];\n      const currentIndex = themes.indexOf(currentTheme);\n      const nextIndex = (currentIndex + 1) % themes.length;\n      this.themeSignal.set(themes[nextIndex]);\n    } catch (error) {\n      console.error('Failed to toggle theme:', error);\n    }\n  }\n\n  // Utility methods\n  isDark(): boolean {\n    return this.resolvedTheme() === 'dark';\n  }\n\n  isLight(): boolean {\n    return this.resolvedTheme() === 'light';\n  }\n\n  isSystem(): boolean {\n    return this.themeSignal() === 'system';\n  }\n\n  ngOnDestroy(): void {\n    this.isDestroyed = true;\n    this.cleanup();\n  }\n\n  cleanup(): void {\n    try {\n      this.mediaManager.removeChangeListener(this.systemThemeChangeListener);\n      this.mediaManager.cleanup();\n    } catch (error) {\n      console.warn('Error during ThemeService cleanup:', error);\n    }\n  }\n\n  // Private methods\n  private setupManagers(): void {\n    this.storageManager?.setup();\n    this.mediaManager.setup(this.config);\n    this.mediaManager.addChangeListener(this.systemThemeChangeListener);\n  }\n\n  private loadInitialTheme(): void {\n    const loadedTheme = this.storageManager?.loadTheme(this.storageKey) ?? this.config.defaultTheme;\n    this.themeSignal.set(loadedTheme);\n\n    const systemTheme = this.mediaManager.updateSystemTheme();\n    this.systemThemeSignal.set(systemTheme);\n  }\n\n  private setFallbackThemes(): void {\n    this.themeSignal.set('light');\n    this.systemThemeSignal.set('light');\n    this.isInitialized = true;\n  }\n\n  private handleSystemThemeChange(): void {\n    if (!this.isDestroyed) {\n      const systemTheme = this.mediaManager.updateSystemTheme();\n      this.systemThemeSignal.set(systemTheme);\n    }\n  }\n\n  // Effects setup - only called in browser environment\n  private setupEffects(): void {\n    if (!isPlatformBrowser(this.platformId)) {\n      return;\n    }\n    effect(\n      () => {\n        const resolvedTheme = this.resolvedTheme();\n        if (resolvedTheme !== this.lastAppliedTheme) {\n          applyTheme(resolvedTheme, this.themeStrategies);\n          this.lastAppliedTheme = resolvedTheme;\n        }\n      },\n      { injector: this.injector },\n    );\n\n    effect(\n      () => {\n        const theme = this.themeSignal();\n        if (!this.config.forcedTheme && !this.isDestroyed) {\n          this.storageManager?.saveTheme(this.storageKey, theme);\n        }\n      },\n      { injector: this.injector },\n    );\n  }\n}\n","import { Provider } from '@angular/core';\n\nexport enum ThemeFeatureKind {\n  CONFIG,\n  STORAGE,\n  STRATEGIES,\n}\n\ndeclare interface ThemeFeature<KindT extends ThemeFeatureKind> {\n  kind: KindT;\n  providers: Provider[];\n}\n\nexport declare type ThemeConfigFeature = ThemeFeature<ThemeFeatureKind.CONFIG>;\nexport declare type ThemeStorageFeature = ThemeFeature<ThemeFeatureKind.STORAGE>;\nexport declare type ThemeStrategiesFeature = ThemeFeature<ThemeFeatureKind.STRATEGIES>;\n\nexport declare type ThemeFeatures = ThemeConfigFeature | ThemeStorageFeature | ThemeStrategiesFeature;\n","import { Injectable } from '@angular/core';\n\nimport { Theme, ThemeStorageManager } from './theme.types';\n\n@Injectable()\nexport class ThemeLocalStorageManager implements ThemeStorageManager {\n  storage?: Storage;\n\n  setup(): void {\n    try {\n      const testKey = '__theme_test__';\n      localStorage.setItem(testKey, 'test');\n      localStorage.removeItem(testKey);\n      this.storage = localStorage;\n    } catch (error) {\n      console.warn('localStorage is not available, theme preferences will not be persisted:', error);\n    }\n  }\n\n  loadTheme(storageKey: string) {\n    if (!this.storage) {\n      return undefined;\n    }\n    try {\n      const storedTheme = this.storage.getItem(storageKey);\n\n      if (storedTheme && ['light', 'dark', 'system'].includes(storedTheme)) {\n        return storedTheme as Theme;\n      } else {\n        if (storedTheme) {\n          this.storage.removeItem(storageKey);\n        }\n      }\n    } catch (error) {\n      console.warn('Failed to load theme from storage:', error);\n    }\n\n    return undefined;\n  }\n\n  saveTheme(storageKey: string, theme: Theme): void {\n    if (!this.storage) return;\n\n    try {\n      this.storage.setItem(storageKey, theme);\n    } catch (error) {\n      console.warn('Failed to save theme to storage:', error);\n    }\n  }\n}\n","import { isPlatformBrowser } from '@angular/common';\nimport { EnvironmentProviders, PLATFORM_ID, inject, makeEnvironmentProviders, provideAppInitializer } from '@angular/core';\n\nimport { DEFAULT_THEME_CONFIG, THEME_CONFIG, THEME_STORAGE_KEY, THEME_STORAGE_MANAGER, THEME_STRATEGIES } from './theme.config';\nimport { ThemeConfigFeature, ThemeFeatureKind, ThemeFeatures, ThemeStorageFeature, ThemeStrategiesFeature } from './theme.feature';\nimport { ThemeService } from './theme.service';\nimport { ThemeLocalStorageManager } from './theme.storage';\nimport { Theme, ThemeConfig, ThemeStorageManager, ThemeStrategy } from './theme.types';\n\nexport function provideTheme(...features: ThemeFeatures[]): EnvironmentProviders {\n  // @ts-expect-error useValue will exist if users configures it\n  const disabledAutoInit = features.find((it) => it.kind === ThemeFeatureKind.CONFIG)?.providers[0]?.['useValue'].enableAutoInit === false;\n  return makeEnvironmentProviders([\n    features.map((it) => it.providers),\n    ...(!disabledAutoInit\n      ? [\n          provideAppInitializer(() => {\n            // Only initialize in browser environment\n            if (isPlatformBrowser(inject(PLATFORM_ID))) {\n              const themeService = inject(ThemeService);\n              themeService.initialize();\n            }\n          }),\n        ]\n      : []),\n  ]);\n}\n\nexport function withThemeConfig(userConfig: {\n  defaultTheme?: Theme;\n  enableAutoInit?: boolean;\n  enableSystem?: boolean;\n  forcedTheme?: Theme;\n}): ThemeConfigFeature {\n  const config = { ...DEFAULT_THEME_CONFIG, ...userConfig } satisfies ThemeConfig;\n  return {\n    kind: ThemeFeatureKind.CONFIG,\n    providers: [{ provide: THEME_CONFIG, useValue: config }],\n  };\n}\n\nexport function withThemeStorage(userConfig?: { key?: string; manager?: ThemeStorageManager }): ThemeStorageFeature {\n  return {\n    kind: ThemeFeatureKind.STORAGE,\n    providers: [\n      ...(userConfig?.key ? [{ provide: THEME_STORAGE_KEY, useValue: userConfig.key }] : []),\n      { provide: THEME_STORAGE_MANAGER, useValue: userConfig?.manager ?? new ThemeLocalStorageManager() },\n    ],\n  };\n}\n\nexport function withThemeStrategies(themeStrategies: ThemeStrategy[]): ThemeStrategiesFeature {\n  return {\n    kind: ThemeFeatureKind.STRATEGIES,\n    providers: [{ provide: THEME_STRATEGIES, useValue: themeStrategies }],\n  };\n}\n","/*\n * Public API Surface of dfx-theme\n */\n\nexport * from './lib';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAEa,kBAAkB,CAAA;IAC7B,UAAU,GAA0B,IAAI;IAChC,WAAW,GAAG,KAAK;AAE3B,IAAA,KAAK,CAAC,MAAmB,EAAA;AACvB,QAAA,IAAI;AACF,YAAA,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,UAAU,IAAI,MAAM,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;gBAClG,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,8BAA8B,CAAC;gBACnE,IAAI,CAAC,iBAAiB,EAAE;YAC1B;QACF;QAAE,OAAO,KAAK,EAAE;AACd,YAAA,OAAO,CAAC,IAAI,CAAC,yDAAyD,EAAE,KAAK,CAAC;QAChF;IACF;IAEA,i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