<?php
require_once "../config.php";

$id = $_GET['id'] ?? '';

$apps = [

    // ============================
    // INTERNAL PHP/HTML APPS
    // ============================
    "filemanager" => [
        "id" => "filemanager",
        "title" => "File Manager",
        "icon" => "assets/icons/folder.png",
        "type" => "internal",
        "url"  => "filemanager.php"
    ],

    "notepad" => [
        "id" => "notepad",
        "title" => "Notepad",
        "icon" => "assets/icons/notepad.png",
        "type" => "internal",
        "url"  => "notepad.php"
    ],

    "calculator" => [
        "id" => "calculator",
        "title" => "Calculator",
        "icon" => "assets/icons/calculator.png",
        "type" => "internal",
        "url"  => "calculator.php"
    ],

    // ============================
    // INTERNAL JS/HTML GAMES
    // ============================
    "games" => [
        "id" => "games",
        "title" => "Games Library",
        "icon" => "assets/icons/games.png",
        "type" => "internal",
        "url"  => "games.html"
    ],

    // ============================
    // EXTERNAL / EMBEDDED APPS
    // ============================
    "emulator" => [
        "id" => "emulator",
        "title" => "EmulatorJS",
        "icon" => "assets/icons/emulator.png",
        "type" => "iframe",
        "url"  => "../external/emulatorjs.html"
    ],

    "chat" => [
        "id" => "chat",
        "title" => "Web Chat",
        "icon" => "assets/icons/chat.png",
        "type" => "iframe",
        "url"  => "../external/chat.html"
    ]
];

if ($id && isset($apps[$id])) {
    echo json_encode($apps[$id]);
    exit;
}

echo json_encode(["error" => "App not found"]);