/* ===== Global State ===== */ window.NAIState = { clientId: localStorage.getItem('nai_client_id') || (() => { const id = 'client_' + Math.random().toString(36).substring(2, 14) + '_' + Date.now(); localStorage.setItem('nai_client_id', id); return id; })(), ws: null, wsReady: false, currentPage: 'generate', generating: false, lastSeed: -1, theme: localStorage.getItem('nai_theme') || 'dark', // Vibe vibeRefImages: [], vibeFiles: [], vibeEncoding: false, pendingGenerateAfterEncode: false, // Extra input extraInputImage: null, extraInputMode: 'img2img', // Mask maskCanvas: null, maskCtx: null, overlayCanvas: null, overlayCtx: null, isPainting: false, brushSize: 30, maskHistory: [], maskHistoryIndex: -1, };