import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import './index.css' import App from './App.jsx' import ErrorBoundary from './components/ErrorBoundary.jsx' import { enableCopyProtection } from './utils/protection.js' // Função para verificar compatibilidade básica function checkBrowserCompatibility() { // Verificar recursos essenciais const requiredFeatures = { fetch: typeof fetch !== 'undefined', Promise: typeof Promise !== 'undefined', Array: typeof Array !== 'undefined' && Array.isArray, Object: typeof Object !== 'undefined', } const missingFeatures = Object.entries(requiredFeatures) .filter(([_, supported]) => !supported) .map(([feature]) => feature) if (missingFeatures.length > 0) { console.error('Recursos não suportados:', missingFeatures) return false } return true } // Função para mostrar mensagem de erro se o React não carregar function showFallbackError() { const root = document.getElementById('root') if (root) { root.innerHTML = `

Carregando...

Se esta mensagem persistir, seu navegador pode não ser compatível.

` } } // Verificar compatibilidade antes de inicializar if (!checkBrowserCompatibility()) { console.error('Navegador não compatível com recursos necessários') showFallbackError() } else { try { // Habilitar proteção contra cópia (com tratamento de erro) try { enableCopyProtection() } catch (e) { console.warn('Erro ao habilitar proteção:', e) } // Verificar se o elemento root existe const rootElement = document.getElementById('root') if (!rootElement) { throw new Error('Elemento #root não encontrado no DOM') } // Tentar criar root e renderizar const root = createRoot(rootElement) root.render( ) } catch (error) { console.error('Erro ao inicializar React:', error) showFallbackError() // Tentar enviar erro para analytics if (window.gtag) { try { window.gtag('event', 'exception', { description: `React initialization error: ${error.toString()}`, fatal: true }) } catch (e) { // Ignorar erros de analytics } } } }