export interface AppConfig { baseRoot: string; baseDashboard: string; baseAuth: string; baseApi: string; view: 'selection' | 'dashboard'; initialGuildId?: string; isAdmin?: boolean; userLabel?: string; } export interface AppState { guildId?: string; isAdmin?: boolean; userLabel?: string; } type Listener = (state: AppState) => void; let config: AppConfig | null = null; let state: AppState = {}; const listeners = new Set(); export function initConfig(next: AppConfig) { config = next; state = { guildId: next.initialGuildId, isAdmin: next.isAdmin, userLabel: next.userLabel }; } export function getConfig() { return config; } export function getState() { return state; } export function setState(partial: Partial) { state = { ...state, ...partial }; listeners.forEach((l) => l(state)); } export function subscribe(listener: Listener) { listeners.add(listener); return () => listeners.delete(listener); }