<!DOCTYPE html>
<html lang="fr">
  <head>
    <!-- Google Tag Manager - Chargement différé -->
    <script>
      // Charger GTM après le chargement de la page pour ne pas bloquer le rendu
      window.addEventListener('load', function() {
        (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
        new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.defer=true;j.src=
        'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
        })(window,document,'script','dataLayer','GTM-NHHN9GB');
      });
    </script>
    <!-- End Google Tag Manager -->
    
    <meta charset="UTF-8" />
    <link rel="icon" type="image/png" href="/assets/logo-be-scale-BS42i1Ky.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, viewport-fit=cover" />
    
    <!-- Primary Meta Tags -->
    <title>BE SCALE - Plateforme de croissance pour entreprises | Audit BE Fit Index™</title>
    <meta name="title" content="BE SCALE - Plateforme de croissance pour entreprises | Audit BE Fit Index™" />
    <meta name="description" content="Découvrez BE SCALE, la plateforme qui transforme votre entreprise. Audit BE Fit Index™ gratuit, solutions personnalisées, IA PilotIA™. +2,500 dirigeants font confiance à BE SCALE pour accélérer leur croissance." />
    <meta name="keywords" content="audit entreprise, croissance business, BE Fit Index, pilotia, conseil stratégique, management, optimisation, transformation digitale, startup, PME, dirigeant" />
    <meta name="author" content="BE SCALE" />
    <meta name="robots" content="index, follow" />
    <link rel="canonical" href="https://be-scale.com" />
    
    <!-- Open Graph / Facebook -->
    <meta property="og:type" content="website" />
    <meta property="og:url" content="https://be-scale.com" />
    <meta property="og:title" content="BE SCALE - Plateforme de croissance pour entreprises | Audit BE Fit Index™" />
    <meta property="og:description" content="Découvrez BE SCALE, la plateforme qui transforme votre entreprise. Audit BE Fit Index™ gratuit, solutions personnalisées, IA PilotIA™. +2,500 dirigeants font confiance à BE SCALE." />
    <meta property="og:image" content="https://be-scale.com/og-image.jpg" />
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="630" />
    <meta property="og:site_name" content="BE SCALE" />
    <meta property="og:locale" content="fr_FR" />
    
    <!-- Twitter -->
    <meta property="twitter:card" content="summary_large_image" />
    <meta property="twitter:url" content="https://be-scale.com" />
    <meta property="twitter:title" content="BE SCALE - Plateforme de croissance pour entreprises" />
    <meta property="twitter:description" content="Audit BE Fit Index™ gratuit + solutions personnalisées + IA PilotIA™. Transformez votre entreprise avec BE SCALE." />
    <meta property="twitter:image" content="https://be-scale.com/twitter-image.jpg" />
    
    <!-- Additional SEO Meta Tags -->
    <meta name="theme-color" content="#000000" />
    <meta name="msapplication-TileColor" content="#000000" />
    <meta name="mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
    <meta name="apple-mobile-web-app-title" content="BE SCALE" />
    
    <!-- Structured Data / JSON-LD -->
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "SoftwareApplication",
      "name": "BE SCALE",
      "description": "Plateforme de croissance pour entreprises avec audit BE Fit Index™ et IA PilotIA™",
      "url": "https://be-scale.com",
      "applicationCategory": "BusinessApplication",
      "operatingSystem": "Web",
      "offers": {
        "@type": "Offer",
        "price": "0",
        "priceCurrency": "EUR",
        "description": "Audit BE Fit Index™ gratuit"
      },
      "aggregateRating": {
        "@type": "AggregateRating",
        "ratingValue": "4.8",
        "ratingCount": "2500"
      },
      "provider": {
        "@type": "Organization",
        "name": "BE SCALE",
        "url": "https://be-scale.com"
      }
    }
    </script>
    
    <!-- Resource Hints for performance -->
    <!-- Preconnect to critical external domains -->
    <link rel="preconnect" href="https://fonts.googleapis.com" />
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
    
    <!-- DNS Prefetch for non-critical external domains -->
    <link rel="dns-prefetch" href="https://www.loom.com" />
    <link rel="dns-prefetch" href="https://images.pexels.com" />
    <link rel="dns-prefetch" href="https://eu.i.posthog.com" />
    <link rel="dns-prefetch" href="https://salesiq.zohopublic.eu" />
    <link rel="dns-prefetch" href="https://www.googletagmanager.com" />
    <link rel="dns-prefetch" href="https://static.hotjar.com" />
    <link rel="dns-prefetch" href="https://analytics.ahrefs.com" />
    
    <!-- Preload critical resources -->
    <!-- Le modulepreload est généré automatiquement par Vite en production -->
    
    <!-- PostHog Analytics -->
    <script>
      // PostHog sera initialisé par le service React si une clé valide est configurée
      // Ce script crée juste un stub pour éviter les erreurs
      if (typeof window !== 'undefined' && !window.posthog) {
        window.posthog = {
          capture: function() { console.debug('🔍 PostHog non configuré - capture ignoré'); },
          identify: function() { console.debug('🔍 PostHog non configuré - identify ignoré'); },
          people: { set: function() { console.debug('🔍 PostHog non configuré - people.set ignoré'); } },
          reset: function() { console.debug('🔍 PostHog non configuré - reset ignoré'); },
          get_distinct_id: function() { return undefined; },
          init: function() { console.debug('🔍 PostHog non configuré - init ignoré'); },
          register: function() { console.debug('🔍 PostHog non configuré - register ignoré'); }
        };
      }
    </script>

    <!-- Zoho SalesIQ : chargement géré par SalesIQLoader (src/components/SalesIQLoader.tsx) -->

    <!-- Polyfill pour 'ws' (WebSocket) - nécessaire pour recharts -->
    <script>
      // Définir ws globalement avant que recharts ne se charge
      // recharts essaie d'utiliser ws() comme une fonction mais ce n'est pas disponible dans le navigateur
      (function() {
        if (typeof window !== 'undefined') {
          // Créer un module ws factice
          const wsStub = function ws() {
            return {};
          };
          wsStub.WebSocket = typeof WebSocket !== 'undefined' ? WebSocket : class {};
          wsStub.Server = class {};
          wsStub.createWebSocketStream = () => ({});
          wsStub.connect = () => ({});
          wsStub.send = () => {};
          wsStub.close = () => {};
          
          // Exposer ws globalement
          window.ws = wsStub;
          
          // Créer un système de modules factice pour intercepter les imports
          if (!window.__vite_plugin_react_preamble_installed__) {
            const originalDefine = window.define;
            window.define = function(name, deps, factory) {
              if (name === 'ws' || (deps && deps.includes('ws'))) {
                return wsStub;
              }
              if (originalDefine) {
                return originalDefine.apply(this, arguments);
              }
            };
          }
        }
      })();
    </script>
    
    <!-- DEBUG: Logs très précoces pour identifier le problème -->
    <script>
      // #region agent log
      (function() {
        const LOG_ENDPOINT = 'http://127.0.0.1:7242/ingest/cc4e20cd-5db6-4867-aa17-38b3b135368f';
        const sessionId = 'debug-session-' + Date.now();
        const runId = 'run1';
        
        function logDebug(location, message, data, hypothesisId) {
          try {
            const payload = {
              sessionId: sessionId,
              runId: runId,
              hypothesisId: hypothesisId || 'A',
              location: location,
              message: message,
              data: data || {},
              timestamp: Date.now()
            };
            fetch(LOG_ENDPOINT, {
              method: 'POST',
              headers: {'Content-Type': 'application/json'},
              body: JSON.stringify(payload)
            }).catch(() => {});
            console.log('[DEBUG]', location, message, data);
          } catch(e) {
            console.log('[DEBUG]', location, message, data);
          }
        }
        
        // Log immédiatement - vérifier si le script s'exécute
        logDebug('index.html:inline', 'Script inline dans index.html exécuté', {
          readyState: document.readyState,
          hasWindow: typeof window !== 'undefined',
          hasDocument: typeof document !== 'undefined'
        }, 'A');
        
        // Vérifier si le root existe
        document.addEventListener('DOMContentLoaded', function() {
          logDebug('index.html:DOMContentLoaded', 'DOMContentLoaded déclenché', {
            rootExists: !!document.getElementById('root')
          }, 'A');
        });
        
        // Capturer les erreurs avant que main.tsx ne charge
        window.addEventListener('error', function(event) {
          logDebug('index.html:error', 'Erreur JavaScript capturée', {
            message: event.message,
            filename: event.filename,
            lineno: event.lineno,
            colno: event.colno,
            error: event.error ? event.error.toString() : 'N/A'
          }, 'B');
        });
        
        // Capturer les promesses rejetées
        window.addEventListener('unhandledrejection', function(event) {
          logDebug('index.html:unhandledrejection', 'Promise rejetée', {
            reason: event.reason ? event.reason.toString() : 'N/A'
          }, 'B');
        });
        
        // Vérifier si le script main.tsx se charge
        const mainScript = document.querySelector('script[src="/src/main.tsx"]');
        if (mainScript) {
          logDebug('index.html:script-check', 'Script main.tsx trouvé dans le DOM', {
            src: mainScript.getAttribute('src'),
            type: mainScript.getAttribute('type')
          }, 'C');
          
          mainScript.addEventListener('load', function() {
            logDebug('index.html:script-load', 'Script main.tsx chargé avec succès', {}, 'C');
          });
          
          mainScript.addEventListener('error', function(event) {
            logDebug('index.html:script-error', 'Erreur lors du chargement de main.tsx', {
              error: event.toString()
            }, 'C');
          });
        } else {
          logDebug('index.html:script-check', 'Script main.tsx NON trouvé dans le DOM', {}, 'C');
        }
        
        // Vérifier le service worker
        if ('serviceWorker' in navigator) {
          navigator.serviceWorker.getRegistrations().then(function(registrations) {
            logDebug('index.html:sw-check', 'Service workers trouvés', {
              count: registrations.length,
              scripts: registrations.map(function(r) {
                return r.active ? r.active.scriptURL : 'N/A';
              })
            }, 'D');
          }).catch(function(err) {
            logDebug('index.html:sw-error', 'Erreur lors de la vérification des SW', {
              error: err.toString()
            }, 'D');
          });
        }
        
        logDebug('index.html:init', 'Initialisation des logs terminée', {
          timestamp: new Date().toISOString()
        }, 'A');
      })();
      // #endregion
    </script>
    <script type="module" crossorigin src="/assets/main-D2cHks8N.js"></script>
    <link rel="stylesheet" crossorigin href="/assets/main-DW_oZZ3B.css">
  <script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
  <body>
    <!-- Google Tag Manager (noscript) -->
    <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NHHN9GB"
    height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
    <!-- End Google Tag Manager (noscript) -->
    
    <div id="root"></div>
  </body>
</html>
