/* global React */
// ==================== PORT DE DAKAR — DONNÉES CNUCED ====================
// Indicateurs structurés selon le cadre CNUCED de performance portuaire
// (7 groupes, 94 indicateurs au total — sélection des plus représentatifs)

function getPortDakarData(lang) {
  const FR = lang === "fr";

  // CNUCED group labels
  const G1 = FR ? "1. Gouvernance" : "1. Governance";
  const G2 = FR ? "2. Ressources humaines" : "2. Human resources";
  const G3 = FR ? "3. Finances" : "3. Finance";
  const G4 = FR ? "4. Résilience & cybersécurité" : "4. Resilience & cybersecurity";
  const G5 = FR ? "5. Opérations — navires" : "5. Ship operations";
  const G6 = FR ? "6. Opérations — marchandises" : "6. Cargo operations";
  const G7 = FR ? "7. Durabilité environnementale" : "7. Environmental sustainability";

  const indicators = [
    // 1. GOUVERNANCE
    { code: "1.1.1", group: G1, level: "context", name: FR ? "Statut juridique" : "Legal status", note: FR ? "Établissement public à caractère industriel et commercial (EPIC)" : "Public industrial & commercial entity (EPIC)", textual: true, value: "EPIC", status: "ok" },
    { code: "1.1.2", group: G1, level: "context", name: FR ? "Plan directeur portuaire" : "Port master plan", note: FR ? "Plan stratégique Port 2035 adopté en 2026" : "Strategic Plan Port 2035 adopted 2026", textual: true, value: FR ? "Plan 2035 adopté" : "Plan 2035 adopted", status: "ok" },
    { code: "1.2.1", group: G1, level: "outcome", name: FR ? "Score transparence & reddition de comptes" : "Transparency & accountability score", base: 2.4, target: 4.0, cur: 3.1, unit: "/5", trend: [2.4,2.5,2.7,2.8,3.0,3.0,3.1,3.1], status: "ok", odd: "ODD 16" },
    { code: "1.2.4", group: G1, level: "outcome", name: FR ? "Indice relations ville-port" : "City-port relations index", base: 2.0, target: 4.0, cur: 2.8, unit: "/5", trend: [2.0,2.2,2.3,2.5,2.6,2.7,2.7,2.8], status: "warn", odd: "ODD 11" },
    { code: "IG.1",  group: G1, level: "impact",  name: FR ? "Indice global de gouvernance portuaire" : "Overall port governance index", base: 2.5, target: 4.2, cur: 3.3, unit: "/5", trend: [2.5,2.7,2.9,3.0,3.1,3.2,3.2,3.3], status: "ok", odd: "ODD 16" },

    // 2. RESSOURCES HUMAINES
    { code: "2.1.1", group: G2, level: "outcome", name: FR ? "Parité hommes-femmes — cadres" : "Gender parity — management", base: 0.14, target: 0.30, cur: 0.21, unit: "%", trend: [14,15,16,17,18,19,20,21], status: "ok", odd: "ODD 5" },
    { code: "2.2.3", group: G2, level: "output",  name: FR ? "Emplois directs créés (cumul)" : "Direct jobs created (cumulative)", base: 1840, target: 2400, cur: 2120, unit: "p.", trend: [1840,1880,1920,1980,2030,2070,2100,2120], status: "ok", odd: "ODD 8" },
    { code: "2.3.2", group: G2, level: "output",  name: FR ? "Heures de formation par employé / an" : "Training hours per employee / yr", base: 8, target: 30, cur: 18, unit: "h", trend: [8,10,12,13,14,16,17,18], status: "ok", odd: "ODD 4" },
    { code: "2.4.1", group: G2, level: "outcome", name: FR ? "Productivité par employé" : "Productivity per employee", base: 42, target: 65, cur: 53, unit: "k€/an", trend: [42,44,46,48,50,51,52,53], status: "ok", odd: "ODD 8" },

    // 3. FINANCES
    { code: "3.2.1", group: G3, level: "outcome", name: FR ? "Recettes par EVP traité" : "Revenue per TEU handled", base: 142, target: 185, cur: 168, unit: "€/EVP", trend: [142,148,152,156,160,164,166,168], status: "ok", odd: "ODD 8" },
    { code: "3.3.1", group: G3, level: "output",  name: FR ? "Investissement cumulé de l'OGP" : "Cumulative port authority investment", base: 0, target: 240, cur: 142, unit: "M€", trend: [0,18,42,68,95,118,132,142], status: "ok" },
    { code: "3.3.3", group: G3, level: "outcome", name: FR ? "Part investissement privé / total" : "Private share of total investment", base: 0.18, target: 0.35, cur: 0.28, unit: "%", trend: [18,20,22,24,25,26,27,28], status: "ok" },
    { code: "3.4.1", group: G3, level: "outcome", name: FR ? "Revenu droits de port / revenu total" : "Port dues share of total revenue", base: 0.38, target: 0.45, cur: 0.41, unit: "%", trend: [38,38,39,39,40,40,41,41], status: "ok" },
    { code: "3.4.6", group: G3, level: "outcome", name: FR ? "Ratio d'endettement" : "Debt ratio", base: 0.62, target: 0.50, cur: 0.56, unit: "%", trend: [62,61,60,59,58,57,57,56], status: "warn", invert: true, odd: "ODD 16" },

    // 4. RÉSILIENCE
    { code: "4.1.3", group: G4, level: "outcome", name: FR ? "Fréquence annuelle des accidents (par M.h)" : "Annual accident frequency (per M.h)", base: 4.8, target: 1.5, cur: 2.9, unit: "/M.h", trend: [4.8,4.4,4.0,3.7,3.4,3.2,3.0,2.9], status: "warn", invert: true, odd: "ODD 3" },
    { code: "4.1.5", group: G4, level: "output",  name: FR ? "Dépenses sûreté & sécurité" : "Safety & security spend", base: 1.2, target: 3.5, cur: 2.4, unit: "M€/an", trend: [1.2,1.4,1.7,1.9,2.1,2.2,2.3,2.4], status: "ok", odd: "ODD 9" },
    { code: "4.2.1", group: G4, level: "context", name: FR ? "Niveau de certification cybersécurité (ISO 27001)" : "Cybersecurity certification level (ISO 27001)", base: 0, target: 3, cur: 1, unit: "/3", trend: [0,0,0,1,1,1,1,1], status: "warn", odd: "ODD 9" },
    { code: "4.2.3", group: G4, level: "outcome", name: FR ? "Cyberattaques détectées / an" : "Cyberattacks detected / yr", base: 142, target: 50, cur: 78, unit: "", trend: [142,132,118,108,98,89,82,78], status: "warn", invert: true },

    // 5. OPÉRATIONS NAVIRES
    { code: "5.1.1", group: G5, level: "outcome", name: FR ? "Temps moyen de mouillage" : "Average anchorage time", base: 26, target: 6, cur: 14, unit: "h", trend: [26,24,22,20,18,17,15,14], status: "warn", invert: true, odd: "ODD 9" },
    { code: "5.1.2", group: G5, level: "outcome", name: FR ? "Temps moyen passé au port" : "Average vessel turnaround", base: 72, target: 36, cur: 48, unit: "h", trend: [72,68,64,60,56,52,50,48], status: "warn", invert: true },
    { code: "5.1.5", group: G5, level: "outcome", name: FR ? "Taux d'occupation des postes d'amarrage" : "Berth occupancy rate", base: 0.58, target: 0.78, cur: 0.71, unit: "%", trend: [58,60,63,65,67,69,70,71], status: "ok" },
    { code: "5.2.1", group: G5, level: "context", name: FR ? "Tirant d'eau maximum du quai" : "Maximum quay draught", base: 11.5, target: 14.0, cur: 13.0, unit: "m", trend: [11.5,11.5,11.5,12.0,12.5,12.5,13.0,13.0], status: "ok" },
    { code: "5.2.3", group: G5, level: "context", name: FR ? "Jauge brute moyenne des navires" : "Average gross tonnage", base: 18.5, target: 32.0, cur: 24.5, unit: "kGT", trend: [18.5,19.5,20.5,21.5,22.5,23.0,23.8,24.5], status: "ok" },

    // 6. OPÉRATIONS MARCHANDISES
    { code: "6.1.1.1", group: G6, level: "impact",  name: FR ? "Volume total de marchandises traité" : "Total cargo volume handled", base: 18.4, target: 32.0, cur: 22.6, unit: "Mt/an", trend: [18.4,19.2,20.0,20.6,21.2,21.8,22.2,22.6], status: "ok", odd: "ODD 9" },
    { code: "6.1.1.b", group: G6, level: "outcome", name: FR ? "Conteneurs traités (cumul annuel)" : "Containers handled (annual)", base: 612, target: 1100, cur: 824, unit: "kEVP", trend: [612,640,680,712,748,778,802,824], status: "ok" },
    { code: "6.1.2.1", group: G6, level: "outcome", name: FR ? "Productivité brute par grue" : "Gross crane productivity", base: 18, target: 32, cur: 24, unit: "mvt/h", trend: [18,19,20,21,22,23,23,24], status: "ok" },
    { code: "6.2.2",   group: G6, level: "outcome", name: FR ? "Immobilisation moyenne des conteneurs" : "Average container dwell time", base: 8.4, target: 4.0, cur: 6.2, unit: "j", trend: [8.4,7.9,7.5,7.1,6.8,6.5,6.3,6.2], status: "ok", invert: true },
    { code: "6.2.3",   group: G6, level: "outcome", name: FR ? "Durée moyenne de rotation camion" : "Average truck turnaround", base: 4.6, target: 2.0, cur: 3.1, unit: "h", trend: [4.6,4.2,3.9,3.7,3.5,3.3,3.2,3.1], status: "ok", invert: true },
    { code: "6.3.1",   group: G6, level: "outcome", name: FR ? "Densité de trafic (tonnes / ha utilisé)" : "Traffic density (tons / used ha)", base: 84000, target: 130000, cur: 102000, unit: "t/ha", trend: [84,87,91,94,96,98,100,102], status: "ok" },

    // 7. DURABILITÉ ENVIRONNEMENTALE
    { code: "7.1.1", group: G7, level: "impact",  name: FR ? "Empreinte carbone (par tonne traitée)" : "Carbon footprint per ton handled", base: 14.2, target: 8.5, cur: 11.6, unit: "kgCO₂/t", trend: [14.2,13.8,13.4,13.0,12.6,12.2,11.9,11.6], status: "ok", invert: true, odd: "ODD 13" },
    { code: "7.2.1", group: G7, level: "outcome", name: FR ? "Qualité de l'air (PM10 moyen)" : "Air quality (mean PM10)", base: 68, target: 40, cur: 52, unit: "µg/m³", trend: [68,64,61,58,56,54,53,52], status: "warn", invert: true, odd: "ODD 11" },
    { code: "7.3.1", group: G7, level: "outcome", name: FR ? "Consommation énergétique par EVP" : "Energy consumption per TEU", base: 38, target: 24, cur: 31, unit: "kWh/EVP", trend: [38,36,35,34,33,32,31,31], status: "ok", invert: true, odd: "ODD 7" },
    { code: "7.3.2", group: G7, level: "outcome", name: FR ? "Part d'énergie renouvelable" : "Renewable energy share", base: 0, target: 0.35, cur: 0.12, unit: "%", trend: [0,2,4,5,7,9,11,12], status: "warn", odd: "ODD 7" },
    { code: "7.4.3", group: G7, level: "outcome", name: FR ? "Part de déchets recyclés" : "Recycled waste share", base: 0.22, target: 0.70, cur: 0.48, unit: "%", trend: [22,28,32,36,40,43,46,48], status: "ok", odd: "ODD 12" },
    { code: "7.7.2", group: G7, level: "context", name: FR ? "Système de management environnemental" : "Environmental management system", base: 0, target: 3, cur: 2, unit: "/3", trend: [0,1,1,1,2,2,2,2], status: "ok", note: FR ? "ISO 14001 en cours — certification prévue 2027" : "ISO 14001 in progress — 2027 target", odd: "ODD 14" },
  ];

  const kpis = [
    { l: FR ? "Avancement" : "Progress",            v: "52%",        s: FR ? "vs plan 58%" : "vs plan 58%",       tone: "accent" },
    { l: FR ? "Décaissé" : "Disbursed",             v: "4.20 M€",     s: "50% " + (FR ? "du budget" : "of budget"), tone: "green" },
    { l: FR ? "Volume marchandises" : "Cargo volume", v: "22.6 Mt",  s: FR ? "+23% vs baseline" : "+23% vs baseline" },
    { l: FR ? "Temps moyen au port" : "Avg port stay", v: "48 h",     s: FR ? "−33% vs baseline 72h" : "−33% vs 72h baseline", tone: "green" },
    { l: FR ? "Empreinte carbone" : "Carbon footprint", v: "11.6",   s: "kgCO₂/t · −18%",                          tone: "green" },
    { l: FR ? "Indice gouvernance" : "Governance index", v: "3.3",   s: "CNUCED · cible 4.2/5" },
  ];

  const milestones = [
    { d: "2024-03-01", t: FR ? "Signature accord de financement AFD · BEI · BM" : "Financing agreement signed (AFD · EIB · WB)", state: "done" },
    { d: "2024-09-15", t: FR ? "Études techniques détaillées Phase 1" : "Phase 1 detailed engineering", state: "done" },
    { d: "2025-01-30", t: FR ? "Démarrage travaux dragage Môle 4 (−14 m)" : "Mole 4 dredging works started (−14 m)", state: "done" },
    { d: "2025-08-20", t: FR ? "Réception 2 portiques STS Super-Post-Panamax" : "Delivery 2 Super-Post-Panamax STS cranes", state: "done" },
    { d: "2026-01-15", t: FR ? "Adoption Plan stratégique Port 2035" : "Strategic Plan Port 2035 adopted", state: "done" },
    { d: "2026-05-01", t: FR ? "Déploiement Port Community System (PCS) — EN COURS" : "Port Community System deployment — IN PROGRESS", state: "cur" },
    { d: "2027-03-10", t: FR ? "Mise en service terminal Sud Phase 1" : "South terminal Phase 1 commissioning", state: "todo" },
    { d: "2028-06-30", t: FR ? "Certification ISO 14001 + ISO 27001" : "ISO 14001 + ISO 27001 certification", state: "todo" },
    { d: "2030-12-31", t: FR ? "Évaluation finale Plan stratégique" : "Strategic plan final evaluation", state: "todo" },
  ];

  const activity = [
    { who: "Cheikh A. Mbaye", role: FR ? "Directeur général" : "CEO",                 a: FR ? "a soumis le tableau de bord CNUCED Q1 2026" : "submitted Q1 2026 CNUCED scorecard",          w: FR ? "il y a 2 h" : "2 h ago",   t: "send",        tone: "accent" },
    { who: "Ndèye F. Diop",   role: FR ? "Directrice exploitation" : "Ops director",  a: FR ? "a validé les statistiques EVP du trimestre" : "validated quarterly TEU statistics",          w: FR ? "il y a 5 h" : "5 h ago",   t: "check",       tone: "green" },
    { who: "Moussa Diagne",   role: "HSE",                                           a: FR ? "a clôturé l'audit sécurité Môle 4" : "closed Mole 4 safety audit",                            w: FR ? "hier" : "yesterday",       t: "shieldCheck", tone: "violet" },
    { who: "Aminata Sow",     role: FR ? "Durabilité" : "Sustainability",             a: FR ? "a publié le rapport empreinte carbone 2025" : "published the 2025 carbon footprint report", w: "2 j",                            t: "fileText",    tone: "green" },
    { who: "Tidiane Kane",    role: FR ? "Directeur commercial" : "Commercial dir.",  a: FR ? "a signé l'avenant concession DP World" : "signed DP World concession amendment",             w: "3 j",                            t: "edit",        tone: "amber" },
    { who: "Amadou Bâ",       role: FR ? "DSI / Cybersécurité" : "CIO / Cyber",        a: FR ? "a lancé l'audit blanc ISO 27001" : "launched ISO 27001 mock audit",                          w: "4 j",                            t: "shieldHalf",  tone: "violet" },
  ];

  const risks = [
    { l: "H", c: FR ? "Concurrence régionale Tema · Lomé · Abidjan" : "Regional competition Tema · Lomé · Abidjan",     m: FR ? "Diversification offres · ZES adossée" : "Service diversification · adjacent SEZ",         p: 5, i: 5 },
    { l: "M", c: FR ? "Surcharge réseau ferroviaire Dakar–Bamako" : "Dakar–Bamako rail saturation",                       m: FR ? "Investissement rail dédié + PPP" : "Dedicated rail investment + PPP",                       p: 4, i: 4 },
    { l: "M", c: FR ? "Cyber-attaque chaîne logistique" : "Logistics chain cyber-attack",                                  m: FR ? "SOC 24/7 · ISO 27001 · sauvegarde isolée" : "24/7 SOC · ISO 27001 · isolated backup",        p: 3, i: 5 },
    { l: "M", c: FR ? "Sédimentation excessive baie de Hann" : "Excessive sedimentation Hann Bay",                          m: FR ? "Dragages d'entretien semestriels" : "Bi-annual maintenance dredging",                        p: 4, i: 3 },
    { l: "L", c: FR ? "Acceptabilité sociale extension Sud" : "Social acceptability of South extension",                    m: FR ? "Concertation continue + emplois locaux" : "Ongoing consultation + local jobs",               p: 2, i: 3 },
    { l: "M", c: FR ? "Volatilité prix carburant marin" : "Marine fuel price volatility",                                   m: FR ? "Couverture trimestrielle · PPP énergie" : "Quarterly hedging · energy PPP",                  p: 4, i: 3 },
  ];

  const files = [
    { n: "Plan-directeur-Port-Dakar-2035.pdf",     s: "9.2 MB",  w: "Cheikh A. Mbaye", d: FR ? "il y a 2 sem" : "2 wk ago",  t: "fileText" },
    { n: "CNUCED-PPI-baseline-2024.xlsx",          s: "412 KB",  w: "Aminata Sow",      d: "1 m",                              t: "spreadsheet" },
    { n: "EIES-extension-Sud-Mole4.pdf",           s: "14.8 MB", w: "Moussa Diagne",    d: "1 m",                              t: "fileText" },
    { n: "Convention-concession-DPWorld.docx",     s: "688 KB",  w: "Tidiane Kane",     d: FR ? "il y a 3 j" : "3 d ago",      t: "fileText" },
    { n: "ISO27001-audit-blanc-2026.pdf",          s: "2.1 MB",  w: "Amadou Bâ",        d: FR ? "il y a 5 j" : "5 d ago",      t: "fileText" },
    { n: "Rapport-empreinte-carbone-2025.xlsx",    s: "284 KB",  w: "Aminata Sow",      d: FR ? "il y a 1 sem" : "1 wk ago",   t: "spreadsheet" },
    { n: "Cartographie-mouvements-EVP-2025.geojson", s: "1.4 MB", w: "Ndèye F. Diop",   d: "2 m",                              t: "map" },
    { n: "Plan-urgence-cyber-v2.pdf",              s: "920 KB",  w: "Amadou Bâ",        d: "2 m",                              t: "fileText" },
  ];

  // Sites = postes à quai / môles
  const sites = [
    { c: "SN", n: "Môle 1",                       t: FR ? "Conteneurs" : "Containers",          reg: FR ? "Quai Nord" : "North quay",     b: "284 kEVP",  s: "ok",   ind: 11 },
    { c: "SN", n: "Môle 2",                       t: FR ? "Vracs solides" : "Solid bulk",        reg: FR ? "Quai Centre" : "Centre quay",  b: "4.8 Mt",    s: "ok",   ind: 8 },
    { c: "SN", n: "Môle 3",                       t: FR ? "Hydrocarbures" : "Hydrocarbons",      reg: FR ? "Quai Sud" : "South quay",      b: "6.2 Mt",    s: "ok",   ind: 9 },
    { c: "SN", n: "Môle 4",                       t: FR ? "Conteneurs (extension)" : "Containers (extension)", reg: FR ? "Quai Nord" : "North quay",       b: "540 kEVP",  s: "warn", ind: 14 },
    { c: "SN", n: "Môle 5",                       t: FR ? "Passagers · ferries" : "Passengers · ferries",      reg: FR ? "Quai Est" : "East quay",          b: "98 k pax",  s: "ok",   ind: 6 },
    { c: "SN", n: "Môle 10",                      t: "Roll-on / Roll-off",                       reg: FR ? "Quai Est" : "East quay",       b: "62 k véh.", s: "ok",   ind: 7 },
    { c: "SN", n: FR ? "Terminal à conteneurs Sud (Phase 2)" : "South Container Terminal (Phase 2)", t: FR ? "En construction" : "Under construction", reg: FR ? "Quai Sud" : "South quay",       b: "—",         s: "warn", ind: 4 },
    { c: "SN", n: FR ? "Plateforme PCS — Port Community System" : "PCS — Port Community System",  t: FR ? "Système d'information" : "IT system",       reg: "DSI",                                  b: FR ? "32 acteurs" : "32 actors", s: "ok", ind: 8 },
  ];

  const team = [
    { n: "Cheikh Anta Mbaye",  r: FR ? "Directeur général" : "Chief Executive Officer",                  l: "Dakar", c: "SN" },
    { n: "Ndèye Fatou Diop",   r: FR ? "Directrice de l'exploitation" : "Director of operations",         l: "Dakar", c: "SN" },
    { n: "Tidiane Kane",       r: FR ? "Directeur commercial & concessions" : "Commercial & concessions director", l: "Dakar", c: "SN" },
    { n: "Mariama Sy",         r: FR ? "Directrice financière" : "Chief Financial Officer",               l: "Dakar", c: "SN" },
    { n: "Moussa Diagne",      r: FR ? "Responsable HSE & sûreté" : "HSE & safety lead",                  l: "Dakar", c: "SN" },
    { n: "Amadou Bâ",          r: FR ? "DSI · responsable cybersécurité" : "CIO · cybersecurity lead",     l: "Dakar", c: "SN" },
    { n: "Aminata Sow",        r: FR ? "Responsable développement durable" : "Sustainability lead",        l: "Dakar", c: "SN" },
    { n: "Ousmane Niang",      r: FR ? "Directeur des concessions" : "Concessions director",              l: "Dakar", c: "SN" },
    { n: "Khady Touré",        r: FR ? "Directrice des ressources humaines" : "HR director",              l: "Dakar", c: "SN" },
    { n: "Birame Diop",        r: FR ? "Communication & relations ville-port" : "Communication & city-port relations", l: "Dakar", c: "SN" },
    { n: "Fatou Mbengue",      r: FR ? "Pilote PCS — Port Community System" : "PCS programme lead",       l: "Dakar", c: "SN" },
    { n: "Mamadou Sané",       r: FR ? "Capitaine de port" : "Harbourmaster",                              l: "Dakar", c: "SN" },
  ];

  const budgetLines = [
    { c: FR ? "Dragage Môle 4 et bassin (−14 m)" : "Mole 4 dredging (−14 m)",        b: 2.80, d: 1.94, e: 0.42 },
    { c: FR ? "2 portiques STS Super-Post-Panamax" : "2 Super-Post-Panamax STS cranes", b: 1.84, d: 1.84, e: 0.00 },
    { c: FR ? "Plateforme Port Community System (PCS)" : "Port Community System platform", b: 0.92, d: 0.34, e: 0.28 },
    { c: FR ? "Cybersécurité · SOC 24/7 · ISO 27001" : "Cybersecurity · 24/7 SOC · ISO 27001", b: 0.58, d: 0.18, e: 0.22 },
    { c: FR ? "Études EIES & Plan stratégique 2035" : "EIES studies & Strategic Plan 2035", b: 0.42, d: 0.36, e: 0.02 },
    { c: FR ? "Plan environnemental & ISO 14001" : "Environmental plan & ISO 14001", b: 0.60, d: 0.18, e: 0.14 },
    { c: FR ? "Formation personnel (CNUCED)" : "Staff training (UNCTAD)",            b: 0.36, d: 0.21, e: 0.05 },
    { c: FR ? "Suivi-évaluation & reporting CNUCED" : "M&E and UNCTAD reporting",     b: 0.28, d: 0.10, e: 0.06 },
    { c: FR ? "Concertation ville-port & inclusion" : "City-port consultation & inclusion", b: 0.20, d: 0.05, e: 0.03 },
    { c: FR ? "Pilotage & supervision" : "Programme management",                      b: 0.40, d: 0.20, e: 0.05 },
  ];

  return { kpis, indicators, milestones, activity, risks, files, sites, team, budgetLines };
}

window.getPortDakarData = getPortDakarData;
