<!doctype html>
<html lang="de">

  <head>
    <meta charset="UTF-8" />
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1" />
    <meta name="description" content="Nexo - Personal Finance & Tax Assistant. Verwalten Sie Ihre Finanzen, Rechnungen, Termine und Steuern." />
    <meta name="theme-color" content="#000000" />
    <meta http-equiv="Content-Security-Policy" content="default-src 'self'; base-uri 'self'; object-src 'none'; img-src 'self' data: blob: https://www.googletagmanager.com https://www.google-analytics.com https://www.gstatic.com https://www.google.com https://firebasestorage.googleapis.com; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' data: https://fonts.gstatic.com; script-src 'self' 'unsafe-inline' 'unsafe-eval' https://www.google.com https://www.gstatic.com https://www.recaptcha.net https://www.googletagmanager.com https://www.google-analytics.com; script-src-elem 'self' 'unsafe-inline' https://www.google.com https://www.gstatic.com https://www.recaptcha.net https://www.googletagmanager.com https://www.google-analytics.com; connect-src 'self' https://www.google.com https://www.gstatic.com https://www.recaptcha.net https://www.googletagmanager.com https://www.google-analytics.com https://*.googleapis.com https://*.firebaseio.com https://*.cloudfunctions.net https://firebasestorage.googleapis.com wss://*.firebaseio.com; frame-src 'self' https://www.google.com https://www.recaptcha.net; worker-src 'self' blob:;" />
    <title>Nexo - Personal Finance & Tax Assistant</title>
    <!-- PDF.js worker will be configured by pdfWorkerConfig.ts and ReceiptViewer.tsx -->
    <!-- No need to set it here - Vite's ?url import handles it correctly -->
    <!-- Domain redirect script - Redirect Firebase URLs to custom domain -->
    <script>
      (function() {
        // Redirect Firebase hosting URLs to custom domain
        var hostname = window.location.hostname;
        if (hostname === 'nexo-jtsky100.web.app' || hostname === 'nexo-jtsky100.firebaseapp.com') {
          window.location.href = 'https://nexo.report' + window.location.pathname + window.location.search;
          return;
        }
        
        // Check if user is on a mobile device
        var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
        // Check screen width as fallback
        var isSmallScreen = window.innerWidth <= 768;
        // Check if user has explicitly chosen desktop version
        var preferDesktop = localStorage.getItem('preferDesktop') === 'true';
        
        if ((isMobile || isSmallScreen) && !preferDesktop) {
          // Redirect to mobile version
          window.location.href = 'https://m.nexo.report' + window.location.pathname;
        }
      })();
    </script>
    <link rel="modulepreload" crossorigin href="/assets/vendor-react-CB9EcW9P.js">
    <link rel="modulepreload" crossorigin href="/assets/vendor-firebase-DpqMxOkR.js">
    <link rel="modulepreload" crossorigin href="/assets/vendor-utils-CsoTJ-_o.js">
    <script type="module" crossorigin src="/assets/index-DD8nv81Y.js"></script>
    
    
    
    <link rel="stylesheet" crossorigin href="/assets/index-DLgRKpfi.css">
  
    <script>
      // IMMEDIATE auto-fix for CDN cache issues - runs before any other scripts
      (function() {
        // Only run if we don't already have a cache-busting parameter
        if (window.location.search.includes('_cb=')) return;
        
        // Get the expected script filename from the HTML
        const scriptTag = document.querySelector('script[type="module"][src*="index-"]');
        if (!scriptTag) return;
        
        const expectedScript = scriptTag.src.split('/').pop();
        
        // Immediately check if the script file exists by trying to fetch it
        fetch(scriptTag.src, { method: 'HEAD', cache: 'no-store' })
          .then(response => {
            // If we get HTML instead of JavaScript, it's a 404/cache issue
            const contentType = response.headers.get('content-type') || '';
            if (!contentType.includes('javascript') || response.status === 404) {
              console.warn('[Cache Fix] JavaScript file not found or wrong content type, reloading with cache-busting...');
              const url = new URL(window.location.href);
              url.searchParams.set('_cb', Date.now());
              window.location.replace(url.toString());
            }
          })
          .catch(() => {
            // Network error - might be cache issue, reload with cache-busting
            console.warn('[Cache Fix] Network error, reloading with cache-busting...');
            const url = new URL(window.location.href);
            url.searchParams.set('_cb', Date.now());
            window.location.replace(url.toString());
          });
        
        // Also listen for script load errors
        scriptTag.addEventListener('error', function() {
          console.warn('[Cache Fix] JavaScript file failed to load, reloading with cache-busting...');
          const url = new URL(window.location.href);
          url.searchParams.set('_cb', Date.now());
          window.location.replace(url.toString());
        }, { once: true });
        
        // Fallback: check after timeout if React hasn't loaded
        setTimeout(function() {
          if (!window.React && !document.getElementById('root')?.hasChildNodes()) {
            console.warn('[Cache Fix] React not loaded after timeout, reloading with cache-busting...');
            const url = new URL(window.location.href);
            url.searchParams.set('_cb', Date.now());
            window.location.replace(url.toString());
          }
        }, 3000);
      })();
    </script>
  </head>

  <body>
    <div id="root"></div>
    <script>
      // Register Service Worker for Background Sync
      if ('serviceWorker' in navigator) {
        window.addEventListener('load', () => {
          navigator.serviceWorker.register('/sw.js')
            .then((registration) => {
              console.log('[Service Worker] Registered successfully:', registration.scope);
            })
            .catch((error) => {
              console.error('[Service Worker] Registration failed:', error);
            });
        });
      }
    </script>
  </body>

</html>
