\n\n","src/main.tsx":"import React from 'react';\nimport ReactDOM from 'react-dom/client';\nimport { BrowserRouter as Router, Route, Routes } from 'react-router-dom';\nimport './styles.css';\nimport TextDisplay from './components/TextDisplay';\n\nconst App = () => {\n return (\n \n \n } />\n \n \n );\n};\n\nconst root = ReactDOM.createRoot(document.getElementById('root'));\nroot.render();\n","src/App.tsx":"// This file is no longer needed as main.tsx handles routing and component rendering.","src/components/TextDisplay.tsx":"import React from 'react';\n\ninterface TextDisplayProps {\n content: string;\n style: React.CSSProperties;\n}\n\nconst TextDisplay: React.FC = ({ content, style }) => {\n return (\n
\n {content}\n
\n );\n};\n\nexport default TextDisplay;\n","src/styles.css":"/* Global Styles */\n@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\n:root {\n --primary-color: #00FF00;\n}\n\nbody {\n @apply bg-gray-100 text-gray-900;\n}\n\n/* Utility classes for common styling */\n.text-center {\n @apply text-center;\n}\n\n.text-white {\n @apply text-white;\n}\n\n.p-5 {\n @apply p-5;\n}\n\n.text-lg {\n @apply text-lg;\n}\n"}; function resolvePath(base, relative) { if (!relative.startsWith('.')) return relative; const stack = base.split('/'); stack.pop(); const parts = relative.split('/'); for (let i = 0; i < parts.length; i++) { if (parts[i] === '.') continue; if (parts[i] === '..') stack.pop(); else stack.push(parts[i]); } return stack.join('/'); } function getFileContent(path) { if (window.__SOURCES__[path]) return { content: window.__SOURCES__[path], finalPath: path }; const extensions = ['.tsx', '.ts', '.jsx', '.js', '.css', '.json']; for (let ext of extensions) { if (window.__SOURCES__[path + ext]) return { content: window.__SOURCES__[path + ext], finalPath: path + ext }; } for (let ext of extensions) { if (window.__SOURCES__[path + '/index' + ext]) return { content: window.__SOURCES__[path + '/index' + ext], finalPath: path + '/index' + ext }; } return null; } // --- SMART ROUTER --- // Ensures only ONE Router is ever active at the top level. // Subsequent routers become transparent passthroughs. window.__ROUTER_INITIALIZED__ = false; const SmartRouter = ({ children }) => { const React = window.React; const { HashRouter } = window.ReactRouterDOM; if (window.__ROUTER_INITIALIZED__) { // Already have a router, just render children return React.createElement(React.Fragment, {}, children); } window.__ROUTER_INITIALIZED__ = true; return React.createElement(HashRouter, {}, children); }; window.require = function(path, base = '') { // --- BUILT-INS --- if (path === 'react') return window.React; if (path === 'react-dom') return window.ReactDOM; if (path === 'react-dom/client') return window.ReactDOM; if (path === '@supabase/supabase-js') return window.supabase || createSafeProxy({}, '@supabase/supabase-js'); if (path === 'lucide-react') return window.lucide || createSafeProxy({}, 'lucide-react'); // --- ROUTER SHIM (CRITICAL FIX) --- if (path === 'react-router-dom') { const rrd = window.ReactRouterDOM || {}; return { ...rrd, BrowserRouter: SmartRouter, HashRouter: SmartRouter, MemoryRouter: SmartRouter, ...createSafeProxy(rrd, 'react-router-dom') }; } const resolvedPath = resolvePath(base, path); const fileInfo = getFileContent(resolvedPath); if (!fileInfo) { console.warn('Module not found:', path, 'Resolved:', resolvedPath); return createSafeProxy({}, path); } const { content, finalPath } = fileInfo; if (window.__MODULES__[finalPath]) return window.__MODULES__[finalPath].exports; if (finalPath.endsWith('.css')) { const style = document.createElement('style'); style.textContent = content; document.head.appendChild(style); window.__MODULES__[finalPath] = { exports: {} }; return {}; } if (finalPath.endsWith('.json')) { try { const json = JSON.parse(content); window.__MODULES__[finalPath] = { exports: json }; return json; } catch(e) {} } // --- COMPILATION (CRITICAL FIX) --- try { // Check for obvious non-code content (AI hallucinations) if (content.trim().indexOf('import ') !== 0 && content.trim().indexOf('export ') === -1 && content.trim().indexOf('<') === -1) { if (content.length < 500 && (content.includes('Remove') || content.includes('Note:') || content.includes('Instructions:'))) { throw new Error("File content appears to be text instructions, not code."); } } const presets = [['env', { modules: 'commonjs' }], 'react']; if (finalPath.endsWith('.ts') || finalPath.endsWith('.tsx')) { presets.push('typescript'); } const transformed = Babel.transform(content, { presets, filename: finalPath }).code; const module = { exports: {} }; const wrapper = new Function('module', 'exports', 'require', transformed); wrapper(module, module.exports, (p) => window.require(p, finalPath)); window.__MODULES__[finalPath] = module; return module.exports; } catch (e) { console.error('Compilation Error in ' + finalPath, e); // Don't throw fatal error, return empty to allow other files to load window.__MODULES__[finalPath] = { exports: {} }; return {}; } }; // --- BOOTSTRAP --- window.onload = function() { try { const rootEl = document.getElementById('root'); if (!rootEl) throw new Error("Missing #root element"); // 1. AUTO-DETECT APP COMPONENT // Prefer App.tsx as the root component const appFile = ['src/App.tsx', 'src/App.jsx', 'src/App.js', 'App.tsx', 'App.jsx', 'App.js'].find(p => window.__SOURCES__[p]); let mounted = false; if (appFile) { try { const mod = window.require(appFile); const App = mod.default || mod.App; if (App) { const React = window.React; const ReactDOM = window.ReactDOM; const root = ReactDOM.createRoot(rootEl); // Use SmartRouter to initialize context safely root.render(React.createElement(SmartRouter, {}, React.createElement(App))); mounted = true; console.log('Mounted App via ' + appFile); } } catch(e) { console.warn('Auto-mount failed:', e); } } // 2. FALLBACK: EXECUTE ENTRY FILE (main.tsx) if (!mounted) { const entry = "src/main.tsx"; if (entry && window.__SOURCES__[entry]) { console.log('Executing entry: ' + entry); window.require(entry); } else if (!appFile) { document.body.innerHTML = '
Waiting for entry point...
'; } } } catch (e) { console.error('Bootstrap Error:', e); window.onerror(e.message, '', 0, 0, e); } };