// App Manager - Dynamic app loading with beautiful styling class AppManager { constructor() { this.cache = new Map(); } getRandomLoadingMessage() { const messages = [ "Preparing your application settings...", "Gathering application information...", "Loading application configuration...", "Setting up your app management panel...", "Loading the perfect app settings...", "Crafting your application experience...", "Preparing your app control panel...", "Loading application details...", "Setting up your app workspace...", "Configuring your application environment..." ]; return messages[Math.floor(Math.random() * messages.length)]; } async loadApp(appName) { //console.log(`AppManager: Loading ${appName} app...`); // Check cache first if (this.cache.has(appName)) { //console.log(`AppManager: Using cached ${appName} app`); return this.cache.get(appName); } try { // Load app data from apps.json const response = await fetch('/data/apps/generated/apps.json', { cache: 'no-store' }); if (!response.ok) { throw new Error(`Failed to load apps.json: ${response.status}`); } const appsData = await response.json(); // Try multiple ways to find the app let app = appsData.apps.find(app => app.name.toLowerCase().includes(appName.toLowerCase()) || app.command.toLowerCase().includes(appName.toLowerCase()) || app.name === appName || app.name.toLowerCase() === appName.toLowerCase() ); if (!app) { // Try case-insensitive exact match app = appsData.apps.find(app => app.name.toLowerCase() === appName.toLowerCase() || app.command.toLowerCase().includes(appName.toLowerCase()) ); } if (!app) { //console.log(`Available apps:`, appsData.apps.map(a => ({ name: a.name, command: a.command }))); throw new Error(`App ${appName} not found`); } //console.log(`AppManager: Loaded ${appName} app:`, app); // Cache the result this.cache.set(appName, app); return app; } catch (error) { console.error(`AppManager: Error loading ${appName} app:`, error); return null; } } async renderApp(appName) { //console.log(`AppManager: Rendering ${appName} app...`); const configSection = document.getElementById('config-section'); if (!configSection) { console.error('AppManager: config-section element not found'); return; } // Show loading with enhanced visual configSection.innerHTML = `
${app.description || 'Manage settings and configuration for ' + (app.displayName || app.name)}