import React, { useEffect, useState } from 'react' import ReactDOM from 'react-dom/client' import maplibregl from 'maplibre-gl' import App from './App.tsx' import CompareView from './pages/CompareView' import IntelligenceDashboard from './pages/IntelligenceDashboard' import { ExecutiveShowcase } from './pages/ExecutiveShowcase' import { TacticalDefenseView } from './pages/TacticalDefenseView' import './index.css' maplibregl.setRTLTextPlugin( 'https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.2.3/mapbox-gl-rtl-text.min.js', (err) => { if (err) console.error(err); }, true ); // Lightweight hash router const NAV = [ { hash: '#tactical', label: 'المنظومة التكتيكية العسكرية', icon: '🎖️' }, { hash: '#map', label: 'الخريطة والطقس', icon: '🗺️' }, { hash: '#review', label: 'تدقيق الطرق', icon: '🔍' }, { hash: '#compare', label: 'المقارنة المرجعية', icon: '⚖️' }, { hash: '#executive', label: 'العرض الاستراتيجي', icon: '🏛️' }, ] function ViewNav({ hash }: { hash: string }) { const currentHash = hash || '#tactical' return (
{NAV.map(n => { const active = currentHash === n.hash return ( {n.icon} {n.label} ) })}
) } class ErrorBoundary extends React.Component<{ children: React.ReactNode }, { hasError: boolean; error: any }> { constructor(props: any) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: any) { return { hasError: true, error }; } componentDidCatch(error: any, errorInfo: any) { console.error('App UI Error:', error, errorInfo); } render() { if (this.state.hasError) { return (
⚠️

حدث خطأ أثناء تحميل الواجهة

{this.state.error?.message || 'تعذر تحميل أحد مكونات الخريطة'}

); } return this.props.children; } } function Root() { const [hash, setHash] = useState(window.location.hash || '#tactical'); useEffect(() => { const on = () => { const h = window.location.hash || '#tactical'; setHash(h); setTimeout(() => { window.dispatchEvent(new Event('resize')); }, 50); }; window.addEventListener('hashchange', on); return () => window.removeEventListener('hashchange', on); }, []); const isTactical = hash === '#tactical' || hash === '#military'; const isExecutive = hash === '#executive' || hash === '#pitch'; const isCompare = hash === '#compare'; const isReview = hash === '#review'; const isMap = !isTactical && !isExecutive && !isCompare && !isReview; return ( {isTactical && (
)} {isExecutive && (
)} {isCompare && (
)} {isReview && (
)} {isMap && (
)}
); } ReactDOM.createRoot(document.getElementById('root')!).render();