// [TSM.ID].[11031972] -- All Rights Reserved. Proprietary & Confidential.
import React, { createContext, useState, useContext } from 'react';

const I18nContext = createContext();

const dictionaries = {
  id: {
    welcome: "Selamat Datang di Command Center",
    bandwidth_quota: "Kuota Bandwidth XCU",
    active_streams: "Aliran Media Aktif",
    active_packages: "Paket XCU Aktif",
    billed_via: "Ditagih via DuckDB",
    limit: "Batas",
    month: "Bulan",
    dedicated_load: "Beban XCU Dedikasi",
    routing_topology: "Topologi Routing Kuantum Langsung (Berdasarkan Host CPU/RAM)",
    resource_vis: "Visualisasi Sumber Daya Khusus",
    simulate_identity: "Simulasi Identitas",
    tenant: "Penyewa",
    supreme: "Tertinggi",
    documents: "Dokumen",
    about: "Tentang",
    ouroboros_trigger: "PEMUSNAHAN MUTLAK (PROTOKOL OUROBOROS)",
    ouroboros_desc: "Tindakan ini akan membumihanguskan peladen saat ini secara fisik dan memicu Ouroboros (Reinkarnasi Otomatis Docker).",
    ignite: "SULUT KIAMAT",
    currency_selector: "Mata Uang",
    overview_matrix: "MATRIKS IKHTISAR",
    commercial_forge: "Bursa Komersial",
    commercial_desc: "Tingkatkan atau turunkan spesifikasi modul XCU seketika.",
    omni_bundles: "Paket Raksasa Omni",
    active_bundle: "PAKET AKTIF",
    initiate_handshake: "INISIASI TRANSAKSI",
    purge_bundle: "CABUT PAKET",
    singular_modules: "Matriks Modul Satuan",
    installed: "TERPASANG",
    unlock: "BUKA KUNCI",
    downgrade: "CABUT MODUL",
    financial_matrix: "Matriks Finansial (Tagihan)",
    ledger_id: "ID Buku Besar",
    timestamp: "Stempel Waktu",
    amount_extracted: "Total Ekstraksi",
    clearance_status: "Status Kliring",
    cleared_paid: "LUNAS / SELESAI",
    itemized_receipt: "Kuitansi Kriptografik Rinci",
    total_computed: "TOTAL EKSTRAKSI KOMPUTASI",
    crypto_handshake: "Otorisasi Kriptografik Dibutuhkan",
    warning_destructive: "PERINGATAN: TINDAKAN DESTRUKTIF",
    about_to_purge: "Anda akan MENCABUT modul dari node terdepan. Kapasitas Anda akan seketika anjlok.",
    about_to_unlock: "Anda akan menyuntikkan modul baru secara aman ke dalam node terdepan.",
    value_removed: "NILAI DICABUT",
    transaction_amount: "NILAI TRANSAKSI",
    abort: "BATALKAN",
    confirm_purge: "KONFIRMASI PENCABUTAN",
    confirm_injection: "KONFIRMASI INJEKSI",
    zero_latency: "âœ“ Arsitektur Tanpa-Latensi",
    core_capability: "Kemampuan Inti:",
    ultra_perf: "Didesain untuk performa-ultra dan reduksi latensi mutlak.",
    includes_modules: "Mencakup {count} modul absolut yang didesain untuk kendali dimensi mutlak.",
    core_desc: "Kemampuan inti: {id}. Didesain untuk eksekusi ultra-performa dan reduksi latensi mutlak.",
    supreme_gateway: "GERBANG MATRIKS TERTINGGI",
    login_label: "Otorisasi Akses Kriptografik (Fase 30 IAM Gatekeeper)",
    login_placeholder: "Gunakan awalan SUPREME- atau TENANT-",
    validating_hash: "MEMVALIDASI HASH...",
    init_connection: "INISIALISASI KONEKSI",
    login_footer: "Sistem terhubung secara real-time ke Quantum Pipa. Semua akses tanpa izin akan dicatat dan dieliminasi.",
    access_denied: "Akses Ditolak. Protokol Keamanan Diaktifkan.",
    active_vvip: "Koneksi VVIP Aktif",
    threats_annihilated: "Ancaman Dimusnahkan (24j)",
    session_auth: "Otorisasi Sesi",
    cpu_load: "Beban CPU: {val}% | Inti Tensor: OPTIMAL",
    ram_active: "RAM Aktif: {val}% | Tembok Api: ABSOLUT",
    access_level: "Tingkat Akses:",
    quantum_arsenal: "ARSENAL KUANTUM (TEKNOLOGI ALIEN WASM)",
    wasm_online: "KERNEL WASM ONLINE",
    wasm_compiling: "MENGKOMPILASI WASM...",
    engage_shield: "[ AKTIFKAN PERISAI PASCA-KUANTUM ]",
    engage_watermark: "[ AKTIFKAN TANDA AIR FORENSIK AEGIS ]",
    wasm_logs: "--- LOG EKSEKUSI WASM ---",
    awaiting_command: "Menunggu instruksi komando...",
    global_routing: "TOPOLOGI ROUTING GLOBAL (WEB-TRANSPORT QUIC)",
    unauthorized: "TIDAK SAH",
    aegis_reactor_open: "AEGIS REACTOR OPEN",
    drop_key_to_trigger: "JATUHKAN KUNCI UNTUK MEMICU REAKSI KUANTUM",
    mfa_sequence_activated: "MFA SEQUENCE ACTIVATED",
    mfa_sequence_desc: "Jalur otorisasi teridentifikasi. Sistem menuntut protokol keamanan lanjutan.",
    biometric_pulse_l1: "PULSA BIOMETRIK (L1)",
    scanning: "SCANNING...",
    decrypting_optical_l2: "DECRYPTING OPTICAL SYNC (L2)",
    aegis_keycard_l3: "AEGIS KEYCARD (L3)",
    drag_drop_xcu: "DRAG & DROP .XCU FILE",
    auth_fido2: "INISIASI KONEKSI (FIDO2)",
    authorizing: "AUTHORIZING...",
    or_use_bypass: "ATAU GUNAKAN JALUR BYPASS DARURAT",
    drop_zone: "DROP ZONE",
    aegis_keycard_founder: "AEGIS KEYCARD / KUNCI PENDIRI",
    format_rejected: "FORMAT DITOLAK: Membutuhkan ekstensi .xcu (Aegis Keycard).",
    omni_locked_title: "TENANT JUMPA.ID ENTERPRISE COMMERCIAL",
    omni_locked_active: "PAKET AKTIF: ",
    omni_locked_desc: "Semua 75 Modul Kuantum telah terpasang secara absolut. Paket Raksasa Omni telah dikunci. Anda memiliki kendali penuh atas seluruh ekosistem XCU Ultra."
  },
  en: {
    welcome: "Welcome to Command Center",
    bandwidth_quota: "XCU Bandwidth Quota",
    active_streams: "Active Media Streams",
    active_packages: "Active XCU Packages",
    billed_via: "Billed via DuckDB",
    limit: "Limit",
    month: "Month",
    dedicated_load: "Dedicated XCU Load",
    routing_topology: "Live Quantum Routing Topology (Driven by Host CPU/RAM)",
    resource_vis: "Dedicated Resource Visualization",
    simulate_identity: "Simulate Identity",
    tenant: "Tenant",
    supreme: "Supreme",
    documents: "Documents",
    about: "About",
    ouroboros_trigger: "ABSOLUTE ANNIHILATION (OUROBOROS PROTOCOL)",
    ouroboros_desc: "This action will physically incinerate the current server and trigger Ouroboros (Docker Auto-Reincarnation).",
    ignite: "IGNITE APOCALYPSE",
    currency_selector: "Currency",
    overview_matrix: "OVERVIEW MATRIX",
    commercial_forge: "Commercial Forge",
    commercial_desc: "Upgrade or downgrade XCU modules instantly.",
    omni_bundles: "Omni-Tier Bundles",
    active_bundle: "ACTIVE BUNDLE",
    initiate_handshake: "INITIATE HANDSHAKE",
    purge_bundle: "PURGE BUNDLE",
    singular_modules: "Singular Module Matrix",
    installed: "INSTALLED",
    unlock: "UNLOCK",
    downgrade: "DOWNGRADE",
    financial_matrix: "Financial Matrix (Invoices)",
    ledger_id: "Ledger ID",
    timestamp: "Timestamp",
    amount_extracted: "Amount Extracted",
    clearance_status: "Clearance Status",
    cleared_paid: "CLEARED / PAID",
    itemized_receipt: "Itemized Cryptographic Receipt",
    total_computed: "TOTAL COMPUTED EXTRACT",
    crypto_handshake: "Cryptographic Handshake Required",
    warning_destructive: "WARNING: DESTRUCTIVE ACTION",
    about_to_purge: "You are about to PURGE module from your live edge nodes. Capacity will instantly drop.",
    about_to_unlock: "You are about to securely unlock and inject this module into your live edge nodes.",
    value_removed: "VALUE REMOVED",
    transaction_amount: "TRANSACTION AMOUNT",
    abort: "ABORT",
    confirm_purge: "CONFIRM PURGE",
    confirm_injection: "CONFIRM INJECTION",
    zero_latency: "âœ“ Zero-Latency Architecture",
    core_capability: "Core capability:",
    ultra_perf: "Designed for ultra-performance execution and latency reduction.",
    includes_modules: "Includes {count} ultimate modules designed for absolute dimensional control.",
    core_desc: "Core capability: {id}. Designed for ultra-performance execution and latency reduction.",
    supreme_gateway: "SUPREME MATRIX GATEWAY",
    login_label: "Cryptographic Access Authorization (Phase 30 IAM Gatekeeper)",
    login_placeholder: "Use prefix SUPREME- or TENANT-",
    validating_hash: "VALIDATING HASH...",
    init_connection: "INITIALIZE CONNECTION",
    login_footer: "System is connected real-time to Quantum Pipe. All unauthorized access will be logged and eliminated.",
    access_denied: "Access Denied. Security Protocols Activated.",
    active_vvip: "Active VVIP Connections",
    threats_annihilated: "Threats Annihilated (24h)",
    session_auth: "Session Authorization",
    cpu_load: "CPU Load: {val}% | Tensor Cores: OPTIMAL",
    ram_active: "RAM Active: {val}% | Firewall: ABSOLUTE",
    access_level: "Access Level:",
    quantum_arsenal: "THE QUANTUM ARSENAL (WASM ALIEN TECH)",
    wasm_online: "WASM KERNEL ONLINE",
    wasm_compiling: "WASM COMPILING...",
    engage_shield: "[ ENGAGE POST-QUANTUM SHIELD ]",
    engage_watermark: "[ ENGAGE AEGIS FORENSIC WATERMARK ]",
    wasm_logs: "--- WASM EXECUTION LOGS ---",
    awaiting_command: "Awaiting command instructions...",
    global_routing: "GLOBAL ROUTING TOPOLOGY (WEB-TRANSPORT QUIC)",
    unauthorized: "UNAUTHORIZED",
    aegis_reactor_open: "AEGIS REACTOR OPEN",
    drop_key_to_trigger: "DROP KEY TO TRIGGER QUANTUM REACTION",
    mfa_sequence_activated: "MFA SEQUENCE ACTIVATED",
    mfa_sequence_desc: "Authorization path identified. System demands advanced security protocols.",
    biometric_pulse_l1: "BIOMETRIC PULSE (L1)",
    scanning: "SCANNING...",
    decrypting_optical_l2: "DECRYPTING OPTICAL SYNC (L2)",
    aegis_keycard_l3: "AEGIS KEYCARD (L3)",
    drag_drop_xcu: "DRAG & DROP .XCU FILE",
    auth_fido2: "INITIATE CONNECTION (FIDO2)",
    authorizing: "AUTHORIZING...",
    or_use_bypass: "OR USE EMERGENCY BYPASS ROUTE",
    drop_zone: "DROP ZONE",
    aegis_keycard_founder: "AEGIS KEYCARD / FOUNDER KEY",
    format_rejected: "FORMAT REJECTED: Requires .xcu extension (Aegis Keycard).",
    omni_locked_title: "TENANT JUMPA.ID ENTERPRISE COMMERCIAL",
    omni_locked_active: "ACTIVE BUNDLE: ",
    omni_locked_desc: "All 75 Quantum Modules have been absolutely injected. The Omni Bundle has been locked. You have complete control over the entire XCU Ultra ecosystem."
  }
};

export function I18nProvider({ children }) {
  const [lang, setLang] = useState('id');

  const t = (key) => {
    return dictionaries[lang][key] || key;
  };

  const switchLanguage = (newLang) => {
    if (dictionaries[newLang]) {
      setLang(newLang);
    }
  };

  return (
    <I18nContext.Provider value={{ lang, t, switchLanguage }}>
      {children}
    </I18nContext.Provider>
  );
}

export function useI18n() {
  return useContext(I18nContext);
}
