import './polyfills';

// Production: Disable all console output (prevents seed recovery via console history)
if (import.meta.env.PROD) {
  console.log = () => { };
  console.error = () => { };
  console.warn = () => { };
  console.debug = () => { };
  console.info = () => { };
  console.trace = () => { };
  console.time = () => { };
  console.timeEnd = () => { };
}

// Development: Suppress OpenPGP.js AES cipher warnings
if (import.meta.env.DEV) {
  const originalWarn = console.warn;
  const originalError = console.error;

  console.warn = (...args: any[]) => {
    const msg = args[0]?.toString() || '';
    if (msg.includes('AES-CBC') || msg.includes('AES-CTR') || msg.includes('authentication')) {
      return;
    }
    originalWarn.apply(console, args);
  };

  console.error = (...args: any[]) => {
    const msg = args[0]?.toString() || '';
    if (msg.includes('AES-CBC') || msg.includes('AES-CTR') || msg.includes('authentication')) {
      return;
    }
    originalError.apply(console, args);
  };
}

import { StrictMode } from 'react'
import { createRoot } from 'react-dom/client'
import './index.css'
import App from './App'

if (import.meta.env.DEV) {
  await import('./lib/sessionCrypto');
}

createRoot(document.getElementById('root')!).render(
  <StrictMode>
    <App />
  </StrictMode>,
)
