Spaces:
Running
Running
| /** | |
| * AutonomIA Argentina - Sistema Financiero Autónomo con IA | |
| * Aplicación completamente autónoma potenciada por Groq AI | |
| * Versión: 1.0.0 | |
| * Desarrollado para revolucionar la economía argentina | |
| */ | |
| // Configuración global de la aplicación | |
| const APP_CONFIG = { | |
| name: 'AutonomIA Argentina', | |
| version: '1.0.0', | |
| description: 'Sistema Financiero Autónomo con IA para Argentina', | |
| groq: { | |
| apiUrl: 'https://api.groq.com/openai/v1', | |
| models: ['llama-3.1-8b-instant', 'mixtral-8x7b-32768', 'whisper-large-v3'], | |
| inferenceSpeed: 300, // tokens per second | |
| latency: 0.3 // milliseconds | |
| }, | |
| huggingface: { | |
| optimized: true, | |
| cpuOnly: true, | |
| maxRam: 16, // GB | |
| deployment: 'spaces_free' | |
| } | |
| }; | |
| // Datos de la aplicación - Contenido extenso y realista | |
| const APPLICATION_DATA = { | |
| // Métricas autónomas en tiempo real | |
| autonomousMetrics: { | |
| usersActive: 2847500, | |
| aiDecisionsPerSecond: 15420, | |
| autonomousRedistribution: 78450000000, | |
| aiOptimizationRate: 99.7, | |
| economicAutonomyLevel: 87, | |
| aiConfidenceScore: 0.97 | |
| }, | |
| // Datos económicos en tiempo real | |
| realTimeData: { | |
| pesoDCirculation: 54320000000, | |
| aiManagedFunds: 42100000000, | |
| autonomousTransactions: 8450000, | |
| aiSavingsGenerated: 12300000000, | |
| smartContractsActive: 245000 | |
| }, | |
| // Perfiles de usuarios extensivos | |
| userProfiles: [ | |
| { | |
| id: 1, | |
| name: 'María Elena Rodríguez', | |
| age: 67, | |
| location: 'San Isidro, Buenos Aires', | |
| category: 'jubilada', | |
| aiScore: 8.9, | |
| autonomousBenefit: 2847500, | |
| monthlyIncome: 125000, | |
| aiOptimizedIncome: 550000, | |
| testimony: 'La IA de AutonomIA cambió mi vida completamente. Mis ingresos aumentaron 340% sin hacer nada, todo es completamente automático. La inteligencia artificial maneja todas mis finanzas y optimiza cada peso que tengo.', | |
| aiInteractions: 15420, | |
| satisfactionScore: 9.7, | |
| recommendsToFriends: true | |
| }, | |
| { | |
| id: 2, | |
| name: 'Carlos Alberto Fernández', | |
| age: 34, | |
| location: 'Córdoba Capital', | |
| category: 'emprendedor', | |
| aiScore: 9.2, | |
| autonomousBenefit: 1250000, | |
| monthlyIncome: 280000, | |
| aiOptimizedIncome: 784000, | |
| testimony: 'El sistema autónomo me optimizó todas las inversiones de mi empresa. Ganancia del 180% en solo 6 meses. La IA predice el mercado mejor que cualquier experto humano.', | |
| aiInteractions: 28750, | |
| satisfactionScore: 9.8, | |
| recommendsToFriends: true | |
| }, | |
| { | |
| id: 3, | |
| name: 'Ana Beatriz Silva', | |
| age: 28, | |
| location: 'Rosario, Santa Fe', | |
| category: 'profesional', | |
| aiScore: 8.7, | |
| autonomousBenefit: 890000, | |
| monthlyIncome: 195000, | |
| aiOptimizedIncome: 432000, | |
| testimony: 'La IA predijo perfectamente cada movimiento del mercado. Mis ahorros crecieron sin ninguna intervención humana. Es como tener un genio financiero trabajando 24/7 para mí.', | |
| aiInteractions: 19340, | |
| satisfactionScore: 9.5, | |
| recommendsToFriends: true | |
| }, | |
| { | |
| id: 4, | |
| name: 'Roberto Miguel Torres', | |
| age: 45, | |
| location: 'Mendoza Capital', | |
| category: 'comerciante', | |
| aiScore: 9.1, | |
| autonomousBenefit: 1890000, | |
| monthlyIncome: 320000, | |
| aiOptimizedIncome: 896000, | |
| testimony: 'Mi negocio se automatizó completamente con IA. Las ventas aumentaron 250% y los costos se redujeron 40%. La inteligencia artificial optimiza inventario, precios y logística sin intervención.', | |
| aiInteractions: 32150, | |
| satisfactionScore: 9.6, | |
| recommendsToFriends: true | |
| }, | |
| { | |
| id: 5, | |
| name: 'Lucía Fernanda Morales', | |
| age: 31, | |
| location: 'La Plata, Buenos Aires', | |
| category: 'docente', | |
| aiScore: 8.8, | |
| autonomousBenefit: 760000, | |
| monthlyIncome: 140000, | |
| aiOptimizedIncome: 350000, | |
| testimony: 'Como docente nunca pensé que podría tener estabilidad financiera. La IA me generó ingresos pasivos que superan mi sueldo. Ahora puedo enfocarme en enseñar sin preocuparme por dinero.', | |
| aiInteractions: 14750, | |
| satisfactionScore: 9.4, | |
| recommendsToFriends: true | |
| } | |
| ], | |
| // Marketplace con IA | |
| aiMarketplace: [ | |
| { | |
| id: 1, | |
| name: 'Smartphone AI-Optimized Samsung Galaxy S24 Ultra', | |
| category: 'tecnologia', | |
| precioTradicional: 1250000, | |
| precioAi: 720000, | |
| ahorroIa: 530000, | |
| aiConfidence: 0.94, | |
| optimization: 'Precio optimizado por IA basado en análisis de 15,420 variables de mercado global en tiempo real', | |
| image: '📱', | |
| description: 'El smartphone más avanzado con optimización de precio por IA. Incluye negociación automática con proveedores y detección de ofertas en tiempo real.' | |
| }, | |
| { | |
| id: 2, | |
| name: 'Heladera Inteligente Con IA Samsung RF28T5021', | |
| category: 'hogar', | |
| precioTradicional: 980000, | |
| precioAi: 590000, | |
| ahorroIa: 390000, | |
| aiConfidence: 0.92, | |
| optimization: 'IA negoció directamente con fabricante eliminando 3 intermediarios y optimizando logística', | |
| image: '🧊', | |
| description: 'Heladera inteligente con IA integrada para optimización de consumo energético y gestión automática de inventario de alimentos.' | |
| }, | |
| { | |
| id: 3, | |
| name: 'Notebook Gamer AI-Enhanced ASUS ROG Strix', | |
| category: 'tecnologia', | |
| precioTradicional: 1890000, | |
| precioAi: 1340000, | |
| ahorroIa: 550000, | |
| aiConfidence: 0.96, | |
| optimization: 'Algoritmo de IA analizó 8,750 ofertas globales y negoció precio directo con distribuidor', | |
| image: '💻', | |
| description: 'Laptop gamer de alta performance con optimización de precio por IA y configuración automática para máximo rendimiento.' | |
| }, | |
| { | |
| id: 4, | |
| name: 'Smart TV 65" AI-Optimized Samsung QLED', | |
| category: 'entretenimiento', | |
| precioTradicional: 1450000, | |
| precioAi: 920000, | |
| ahorroIa: 530000, | |
| aiConfidence: 0.93, | |
| optimization: 'IA detectó promoción temporal del fabricante y optimizó momento de compra para máximo ahorro', | |
| image: '📺', | |
| description: 'Smart TV con IA que optimiza contenido, calidad de imagen y consumo energético automáticamente.' | |
| }, | |
| { | |
| id: 5, | |
| name: 'Aire Acondicionado Inteligente LG Dual Inverter', | |
| category: 'hogar', | |
| precioTradicional: 750000, | |
| precioAi: 450000, | |
| ahorroIa: 300000, | |
| aiConfidence: 0.91, | |
| optimization: 'Sistema de IA negoció descuento por volumen y optimizó instalación automática', | |
| image: '❄️', | |
| description: 'Aire acondicionado con IA que aprende patrones de uso y optimiza temperatura y consumo automáticamente.' | |
| }, | |
| { | |
| id: 6, | |
| name: 'Auto Eléctrico Tesla Model 3 AI-Enhanced', | |
| category: 'vehiculos', | |
| precioTradicional: 28500000, | |
| precioAi: 22400000, | |
| ahorroIa: 6100000, | |
| aiConfidence: 0.95, | |
| optimization: 'IA negoció financiación especial y optimizó configuración para máximo ahorro en subsidios', | |
| image: '🚗', | |
| description: 'Vehículo eléctrico con autopiloto mejorado por IA y optimización de rutas y consumo energético.' | |
| } | |
| ], | |
| // Datos de gobernanza | |
| governance: { | |
| decisionLog: [ | |
| { | |
| id: 'decision_1733761200000_abc123', | |
| timestamp: new Date().toISOString(), | |
| model: 'llama-3.1-8b-instant', | |
| context: 'redistribution', | |
| action: 'Redistribuir $2.4M a 1,200 beneficiarios en zona vulnerable', | |
| confidence: 0.97, | |
| executionTime: 0.3, | |
| result: 'success' | |
| }, | |
| { | |
| id: 'decision_1733761260000_def456', | |
| timestamp: new Date(Date.now() - 60000).toISOString(), | |
| model: 'mixtral-8x7b-32768', | |
| context: 'economic', | |
| action: 'Ajustar tasa de interés automática para estabilizar inflación', | |
| confidence: 0.94, | |
| executionTime: 0.4, | |
| result: 'success' | |
| }, | |
| { | |
| id: 'decision_1733761320000_ghi789', | |
| timestamp: new Date(Date.now() - 120000).toISOString(), | |
| model: 'groq_fraud_hunter', | |
| context: 'fraud', | |
| action: 'Bloquear transacción sospechosa de $450,000 en tiempo real', | |
| confidence: 0.99, | |
| executionTime: 0.2, | |
| result: 'blocked' | |
| }, | |
| { | |
| id: 'decision_1733761380000_jkl012', | |
| timestamp: new Date(Date.now() - 180000).toISOString(), | |
| model: 'groq_social_optimizer', | |
| context: 'optimization', | |
| action: 'Optimizar cartera de inversiones de 12,000 usuarios automáticamente', | |
| confidence: 0.95, | |
| executionTime: 0.5, | |
| result: 'optimized' | |
| }, | |
| { | |
| id: 'decision_1733761440000_mno345', | |
| timestamp: new Date(Date.now() - 240000).toISOString(), | |
| model: 'groq_economic_prophet', | |
| context: 'economic', | |
| action: 'Activar compradores automáticos para estabilizar peso digital', | |
| confidence: 0.92, | |
| executionTime: 0.3, | |
| result: 'executed' | |
| } | |
| ], | |
| complianceStatus: { | |
| bcra: { status: 'active', lastCheck: new Date(), score: 9.8 }, | |
| aml: { status: 'monitored', lastCheck: new Date(), score: 9.7 }, | |
| audit: { status: 'continuous', lastCheck: new Date(), score: 9.9 } | |
| }, | |
| smartContracts: { | |
| active: 245000, | |
| executionsDaily: 18500, | |
| successRate: 99.9, | |
| gasOptimized: 87.3 | |
| } | |
| } | |
| }; | |
| // Variables globales de estado | |
| let currentTab = 'dashboard'; | |
| let chartsInstances = {}; | |
| let walletBalance = 2847500; | |
| let isAppInitialized = false; | |
| // Función de utilidad para logging seguro | |
| function safeLog(message, data = null) { | |
| try { | |
| if (data) { | |
| console.log(message, data); | |
| } else { | |
| console.log(message); | |
| } | |
| } catch (e) { | |
| // Silently handle logging errors | |
| } | |
| } | |
| // Función para animar contadores | |
| function animateCounter(element, target, duration = 2000) { | |
| if (!element) return; | |
| const start = parseInt(element.textContent.replace(/[^\d]/g, '')) || 0; | |
| const increment = (target - start) / (duration / 16); | |
| let current = start; | |
| const timer = setInterval(() => { | |
| current += increment; | |
| if ((increment > 0 && current >= target) || (increment < 0 && current <= target)) { | |
| element.textContent = target.toLocaleString(); | |
| clearInterval(timer); | |
| } else { | |
| element.textContent = Math.floor(current).toLocaleString(); | |
| } | |
| }, 16); | |
| } | |
| // Función para cambiar tabs | |
| function switchTab(tabName) { | |
| safeLog('Switching to tab:', tabName); | |
| try { | |
| // Actualizar navegación | |
| document.querySelectorAll('.nav-btn').forEach(btn => { | |
| btn.classList.remove('active'); | |
| }); | |
| const activeBtn = document.querySelector(`[data-tab="${tabName}"]`); | |
| if (activeBtn) { | |
| activeBtn.classList.add('active'); | |
| } | |
| // Cambiar contenido | |
| document.querySelectorAll('.tab-content').forEach(content => { | |
| content.classList.remove('active'); | |
| }); | |
| const activeContent = document.getElementById(tabName); | |
| if (activeContent) { | |
| activeContent.classList.add('active'); | |
| } | |
| currentTab = tabName; | |
| } catch (e) { | |
| safeLog('Error switching tabs:', e); | |
| } | |
| } | |
| // Función para crear gráfico económico | |
| function createEconomicChart() { | |
| const ctx = document.getElementById('economicChart'); | |
| if (!ctx || !window.Chart) return; | |
| try { | |
| const data = { | |
| labels: ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'], | |
| datasets: [ | |
| { | |
| label: 'PIB Optimizado por IA (%)', | |
| data: [2.1, 3.4, 4.7, 5.2, 6.8, 7.3, 7.9, 8.1, 8.4, 8.6, 8.8, 9.1], | |
| backgroundColor: 'rgba(31, 184, 205, 0.2)', | |
| borderColor: '#1FB8CD', | |
| borderWidth: 3, | |
| fill: true, | |
| tension: 0.4 | |
| }, | |
| { | |
| label: 'Reducción de Pobreza (%)', | |
| data: [0, -2.1, -4.5, -6.8, -9.2, -11.5, -13.1, -14.7, -15.2, -16.8, -18.1, -19.5], | |
| backgroundColor: 'rgba(255, 193, 133, 0.2)', | |
| borderColor: '#FFC185', | |
| borderWidth: 3, | |
| fill: true, | |
| tension: 0.4 | |
| } | |
| ] | |
| }; | |
| const config = { | |
| type: 'line', | |
| data: data, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| plugins: { | |
| title: { | |
| display: true, | |
| text: 'Impacto Económico IA en Tiempo Real', | |
| font: { size: 16, weight: 'bold' } | |
| }, | |
| legend: { | |
| position: 'top' | |
| } | |
| }, | |
| scales: { | |
| y: { | |
| beginAtZero: false | |
| } | |
| }, | |
| animation: { | |
| duration: 2000 | |
| } | |
| } | |
| }; | |
| chartsInstances.economic = new Chart(ctx, config); | |
| safeLog('Economic chart created successfully'); | |
| } catch (e) { | |
| safeLog('Error creating economic chart:', e); | |
| } | |
| } | |
| // Función para crear gráfico de redistribución | |
| function createRedistributionChart() { | |
| const ctx = document.getElementById('redistributionChart'); | |
| if (!ctx || !window.Chart) return; | |
| try { | |
| const data = { | |
| labels: ['CABA', 'Buenos Aires', 'Córdoba', 'Santa Fe', 'Mendoza', 'Tucumán'], | |
| datasets: [{ | |
| label: 'Redistribución por IA (Millones $)', | |
| data: [2100, 15700, 8300, 6900, 4200, 3100], | |
| backgroundColor: [ | |
| '#1FB8CD', | |
| '#FFC185', | |
| '#B4413C', | |
| '#ECEBD5', | |
| '#5D878F', | |
| '#DB4545' | |
| ], | |
| borderWidth: 2, | |
| borderColor: '#fff' | |
| }] | |
| }; | |
| const config = { | |
| type: 'doughnut', | |
| data: data, | |
| options: { | |
| responsive: true, | |
| maintainAspectRatio: false, | |
| plugins: { | |
| title: { | |
| display: true, | |
| text: 'Distribución Regional Autónoma', | |
| font: { size: 16, weight: 'bold' } | |
| }, | |
| legend: { | |
| position: 'bottom', | |
| labels: { | |
| padding: 20, | |
| usePointStyle: true | |
| } | |
| } | |
| }, | |
| animation: { | |
| animateRotate: true, | |
| duration: 2000 | |
| } | |
| } | |
| }; | |
| chartsInstances.redistribution = new Chart(ctx, config); | |
| safeLog('Redistribution chart created successfully'); | |
| } catch (e) { | |
| safeLog('Error creating redistribution chart:', e); | |
| } | |
| } | |
| // Función para poblar testimoniales | |
| function populateTestimonials() { | |
| const container = document.getElementById('testimonials-container'); | |
| if (!container) return; | |
| try { | |
| container.innerHTML = ''; // Clear existing content | |
| APPLICATION_DATA.userProfiles.forEach(user => { | |
| const testimonialCard = document.createElement('div'); | |
| testimonialCard.className = 'testimonial-card slide-in-up'; | |
| const initials = user.name.split(' ').map(n => n[0]).join(''); | |
| testimonialCard.innerHTML = ` | |
| <div class="testimonial-header"> | |
| <div class="testimonial-avatar">${initials}</div> | |
| <div class="testimonial-info"> | |
| <h4>${user.name}</h4> | |
| <div class="testimonial-location">${user.location}</div> | |
| </div> | |
| </div> | |
| <div class="testimonial-content"> | |
| "${user.testimony}" | |
| </div> | |
| <div class="testimonial-stats"> | |
| <div class="ai-score">IA Score: ${user.aiScore}/10</div> | |
| <div class="benefit-amount">+$${user.autonomousBenefit.toLocaleString()}</div> | |
| </div> | |
| `; | |
| container.appendChild(testimonialCard); | |
| }); | |
| safeLog('Testimonials populated successfully'); | |
| } catch (e) { | |
| safeLog('Error populating testimonials:', e); | |
| } | |
| } | |
| // Función para poblar marketplace | |
| function populateMarketplace() { | |
| const container = document.getElementById('marketplace-products'); | |
| if (!container) return; | |
| try { | |
| container.innerHTML = ''; // Clear existing content | |
| APPLICATION_DATA.aiMarketplace.forEach(product => { | |
| const productCard = document.createElement('div'); | |
| productCard.className = 'product-card slide-in-up'; | |
| const savingsPercentage = Math.round((product.ahorroIa / product.precioTradicional) * 100); | |
| productCard.innerHTML = ` | |
| <div class="product-image">${product.image}</div> | |
| <div class="product-content"> | |
| <h3 class="product-title">${product.name}</h3> | |
| <div class="product-prices"> | |
| <span class="price-original">$${product.precioTradicional.toLocaleString()}</span> | |
| <span class="price-ai">$${product.precioAi.toLocaleString()}</span> | |
| <span class="price-savings">-${savingsPercentage}%</span> | |
| </div> | |
| <div class="ai-optimization"> | |
| <div class="ai-optimization-title">Optimización IA:</div> | |
| <div class="ai-optimization-desc">${product.optimization}</div> | |
| </div> | |
| <div class="ai-confidence-badge"> | |
| <i class="fas fa-brain"></i> | |
| Confianza IA: ${Math.round(product.aiConfidence * 100)}% | |
| </div> | |
| </div> | |
| `; | |
| container.appendChild(productCard); | |
| }); | |
| safeLog('Marketplace populated successfully'); | |
| } catch (e) { | |
| safeLog('Error populating marketplace:', e); | |
| } | |
| } | |
| // Función para poblar log de gobernanza | |
| function populateGovernanceLog() { | |
| const container = document.getElementById('decision-log'); | |
| if (!container) return; | |
| try { | |
| container.innerHTML = ''; // Clear existing content | |
| APPLICATION_DATA.governance.decisionLog.forEach(decision => { | |
| const decisionItem = document.createElement('div'); | |
| decisionItem.className = 'decision-item slide-in-left'; | |
| const timeStr = new Date(decision.timestamp).toLocaleTimeString(); | |
| decisionItem.innerHTML = ` | |
| <div class="decision-time">${timeStr} - Modelo: ${decision.model}</div> | |
| <div class="decision-action">${decision.action}</div> | |
| <div class="decision-result">Confianza: ${Math.round(decision.confidence * 100)}% | Tiempo: ${decision.executionTime}ms</div> | |
| `; | |
| container.appendChild(decisionItem); | |
| }); | |
| safeLog('Governance log populated successfully'); | |
| } catch (e) { | |
| safeLog('Error populating governance log:', e); | |
| } | |
| } | |
| // Función de optimización de billetera con IA | |
| async function optimizeWalletWithAI() { | |
| const button = document.getElementById('ai-optimize'); | |
| if (!button) return; | |
| try { | |
| const originalText = button.innerHTML; | |
| // Animación de carga | |
| button.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Optimizando...'; | |
| button.disabled = true; | |
| // Simular optimización de IA | |
| await new Promise(resolve => setTimeout(resolve, 2000)); | |
| // Actualizar balance con optimización | |
| const optimizationGain = Math.floor(Math.random() * 5000) + 1000; | |
| walletBalance += optimizationGain; | |
| const balanceElement = document.getElementById('wallet-balance'); | |
| if (balanceElement) { | |
| balanceElement.textContent = walletBalance.toLocaleString(); | |
| } | |
| // Mostrar resultado | |
| button.innerHTML = '<i class="fas fa-check"></i> Optimizado +$' + optimizationGain.toLocaleString(); | |
| button.style.background = 'var(--color-success)'; | |
| // Restaurar botón después de 3 segundos | |
| setTimeout(() => { | |
| button.innerHTML = originalText; | |
| button.disabled = false; | |
| button.style.background = ''; | |
| }, 3000); | |
| safeLog('Wallet optimized:', optimizationGain); | |
| } catch (e) { | |
| safeLog('Error optimizing wallet:', e); | |
| } | |
| } | |
| // Función para descargar la aplicación | |
| function downloadApp() { | |
| try { | |
| safeLog('Iniciando descarga de AutonomIA Argentina...'); | |
| // Crear contenido para descarga | |
| const appContent = { | |
| name: APP_CONFIG.name, | |
| version: APP_CONFIG.version, | |
| description: APP_CONFIG.description, | |
| timestamp: new Date().toISOString(), | |
| data: APPLICATION_DATA, | |
| html: document.documentElement.outerHTML, | |
| instructions: ` | |
| # AutonomIA Argentina - Aplicación Autónoma Completa | |
| ## Instalación | |
| 1. Extraer todos los archivos en una carpeta | |
| 2. Abrir index.html en un navegador web moderno | |
| 3. La aplicación funcionará completamente offline | |
| ## Características | |
| - Sistema financiero completamente autónomo | |
| - Integración con IA Groq para decisiones ultra-rápidas | |
| - Redistribución inteligente de riqueza | |
| - Marketplace con optimización de precios por IA | |
| - Gobernanza transparente y auditable | |
| - Progressive Web App (PWA) | |
| ## Tecnologías | |
| - Frontend: HTML5, CSS3, JavaScript ES6+ | |
| - IA: Simulación de Groq API | |
| - Charts: Chart.js | |
| - Optimizado para: HuggingFace Spaces (CPU) | |
| ## Sistemas Autónomos | |
| - Motor de Redistribución: 2,400 decisiones/min | |
| - Estabilizador Económico: 150 intervenciones/día | |
| - Detección de Fraude: 99.8% precisión | |
| - Optimización de Inversiones: 96.8% tasa de éxito | |
| ## Contacto | |
| Para más información: info@autonomia.ar | |
| Desarrollado con ❤️ para revolucionar la economía argentina | |
| ` | |
| }; | |
| // Crear contenido del archivo ZIP (simulado) | |
| const zipContent = `=== AutonomIA Argentina v${APP_CONFIG.version} === | |
| index.html: | |
| ${document.documentElement.outerHTML} | |
| data.json: | |
| ${JSON.stringify(APPLICATION_DATA, null, 2)} | |
| config.json: | |
| ${JSON.stringify(APP_CONFIG, null, 2)} | |
| README.md: | |
| ${appContent.instructions}`; | |
| const blob = new Blob([zipContent], { type: 'application/zip' }); | |
| const url = URL.createObjectURL(blob); | |
| // Crear enlace de descarga | |
| const link = document.createElement('a'); | |
| link.href = url; | |
| link.download = `autonomia-argentina-v${APP_CONFIG.version}.zip`; | |
| document.body.appendChild(link); | |
| link.click(); | |
| document.body.removeChild(link); | |
| URL.revokeObjectURL(url); | |
| // Mostrar confirmación | |
| const button = document.getElementById('download-app'); | |
| if (button) { | |
| const originalText = button.innerHTML; | |
| button.innerHTML = '<i class="fas fa-check"></i> Descargado'; | |
| button.style.background = 'var(--color-success)'; | |
| setTimeout(() => { | |
| button.innerHTML = originalText; | |
| button.style.background = ''; | |
| }, 3000); | |
| } | |
| safeLog('Download completed successfully'); | |
| } catch (e) { | |
| safeLog('Error downloading app:', e); | |
| } | |
| } | |
| // Función simplificada de inicialización | |
| async function initializeApp() { | |
| safeLog('🚀 Iniciando AutonomIA Argentina...'); | |
| try { | |
| const loadingSteps = [ | |
| 'Conectando con servidores Groq AI...', | |
| 'Inicializando modelos de Machine Learning...', | |
| 'Cargando datos económicos de Argentina...', | |
| 'Activando sistemas autónomos...', | |
| 'Estableciendo conexiones en tiempo real...', | |
| 'Verificando cumplimiento BCRA...', | |
| 'Optimizando para HuggingFace Spaces...', | |
| 'Iniciando motor de redistribución IA...', | |
| 'Activando detección de fraude automática...', | |
| 'Sistema AutonomIA listo para uso...' | |
| ]; | |
| const loadingStatus = document.getElementById('loading-status'); | |
| // Simular proceso de carga más rápido | |
| for (let i = 0; i < loadingSteps.length; i++) { | |
| if (loadingStatus) { | |
| loadingStatus.textContent = loadingSteps[i]; | |
| } | |
| await new Promise(resolve => setTimeout(resolve, 150)); // Reducido de 200ms a 150ms | |
| } | |
| // Ocultar loading screen y mostrar app | |
| const loadingScreen = document.getElementById('loading-screen'); | |
| const app = document.getElementById('app'); | |
| if (loadingScreen && app) { | |
| loadingScreen.style.opacity = '0'; | |
| loadingScreen.style.transition = 'opacity 0.5s ease'; | |
| setTimeout(() => { | |
| loadingScreen.style.display = 'none'; | |
| app.classList.remove('hidden'); | |
| app.style.opacity = '1'; | |
| setupApp(); | |
| }, 500); | |
| } else { | |
| // Fallback si no hay loading screen | |
| setupApp(); | |
| } | |
| } catch (e) { | |
| safeLog('Error during initialization:', e); | |
| // Fallback - setup app anyway | |
| setupApp(); | |
| } | |
| } | |
| // Función para configurar la aplicación después de cargar | |
| function setupApp() { | |
| if (isAppInitialized) return; | |
| try { | |
| safeLog('✅ Configurando AutonomIA Argentina...'); | |
| // Configurar event listeners para navegación | |
| document.querySelectorAll('.nav-btn').forEach(btn => { | |
| btn.addEventListener('click', (e) => { | |
| e.preventDefault(); | |
| const tab = btn.getAttribute('data-tab'); | |
| if (tab) { | |
| switchTab(tab); | |
| } | |
| }); | |
| }); | |
| // Configurar botón de descarga | |
| const downloadBtn = document.getElementById('download-app'); | |
| if (downloadBtn) { | |
| downloadBtn.addEventListener('click', downloadApp); | |
| } | |
| // Configurar botón de optimización de billetera | |
| const aiOptimizeBtn = document.getElementById('ai-optimize'); | |
| if (aiOptimizeBtn) { | |
| aiOptimizeBtn.addEventListener('click', optimizeWalletWithAI); | |
| } | |
| // Poblar contenido inmediatamente | |
| populateTestimonials(); | |
| populateMarketplace(); | |
| populateGovernanceLog(); | |
| // Inicializar gráficos después de un breve delay para asegurar que Chart.js esté cargado | |
| setTimeout(() => { | |
| createEconomicChart(); | |
| createRedistributionChart(); | |
| }, 1000); | |
| // Animar contadores | |
| setTimeout(() => { | |
| const counters = document.querySelectorAll('[data-count]'); | |
| counters.forEach(counter => { | |
| const target = parseInt(counter.getAttribute('data-count')); | |
| if (!isNaN(target)) { | |
| animateCounter(counter, target); | |
| } | |
| }); | |
| }, 500); | |
| // Inicializar balance de billetera | |
| const balanceElement = document.getElementById('wallet-balance'); | |
| if (balanceElement) { | |
| balanceElement.textContent = walletBalance.toLocaleString(); | |
| } | |
| // Iniciar actualizaciones en tiempo real | |
| setInterval(() => { | |
| try { | |
| // Actualizar indicador de IA | |
| const aiIndicator = document.querySelector('.ai-indicator'); | |
| if (aiIndicator) { | |
| aiIndicator.classList.add('active'); | |
| } | |
| // Actualizar balance ocasionalmente | |
| if (Math.random() < 0.1) { // 10% de probabilidad cada 5 segundos | |
| walletBalance += Math.floor(Math.random() * 100) - 30; | |
| const balanceElement = document.getElementById('wallet-balance'); | |
| if (balanceElement) { | |
| balanceElement.textContent = walletBalance.toLocaleString(); | |
| } | |
| } | |
| } catch (e) { | |
| safeLog('Error in real-time updates:', e); | |
| } | |
| }, 5000); | |
| isAppInitialized = true; | |
| safeLog('🎉 AutonomIA Argentina completamente operativa'); | |
| } catch (e) { | |
| safeLog('Error setting up app:', e); | |
| } | |
| } | |
| // Múltiples puntos de entrada para la inicialización | |
| function startApp() { | |
| if (document.readyState === 'loading') { | |
| document.addEventListener('DOMContentLoaded', initializeApp); | |
| } else { | |
| initializeApp(); | |
| } | |
| } | |
| // Iniciar la aplicación | |
| startApp(); | |
| // También intentar inicializar después de que la página esté completamente cargada | |
| window.addEventListener('load', () => { | |
| if (!isAppInitialized) { | |
| setTimeout(setupApp, 100); | |
| } | |
| }); | |
| // Exportar funciones globales para acceso directo | |
| window.AutonomIA = { | |
| config: APP_CONFIG, | |
| data: APPLICATION_DATA, | |
| switchTab: switchTab, | |
| downloadApp: downloadApp, | |
| optimizeWallet: optimizeWalletWithAI, | |
| version: APP_CONFIG.version, | |
| initialized: () => isAppInitialized | |
| }; | |
| safeLog('🌟 AutonomIA Argentina SDK cargado'); |