import { BimDialog } from '../components/dialog'; import type { DialogOptions } from '../components/dialog/index.type'; import type { ThemeConfig } from '../themes/types'; import { themeManager } from '../services/theme'; import { BaseManager } from '../core/base-manager'; import { ManagerRegistry } from '../core/manager-registry'; export class DialogManager extends BaseManager { private container: HTMLElement; private activeDialogs: BimDialog[] = []; constructor(container: HTMLElement, registry: ManagerRegistry) { super(registry); this.container = container; } public create(options: Omit): BimDialog { const dialog = new BimDialog({ container: this.container, ...options, onClose: () => { this.activeDialogs = this.activeDialogs.filter(d => d !== dialog); if (options.onClose) options.onClose(); } }); dialog.setTheme(themeManager.getTheme()); this.activeDialogs.push(dialog); return dialog; } public updateTheme(theme: ThemeConfig) { this.activeDialogs.forEach(dialog => { if (dialog.setTheme) { dialog.setTheme(theme); } }); } public destroy() { this.activeDialogs.forEach(d => d.destroy()); this.activeDialogs = []; super.destroy(); } }