// D:\Dev\Mosis\MosisService\designer\src\app_discovery.h
#pragma once

#include <string>
#include <vector>

namespace mosis {

struct AppInfo {
    std::string id;           // e.g., "com.mosis.sandbox-test"
    std::string name;         // Display name
    std::string version;      // Version string
    std::string entry;        // Entry point (e.g., "main.rml")
    std::string icon;         // Icon filename (e.g., "icon.tga") or path (e.g., "/system/icons/phone.tga")
    std::string description;  // App description
    std::string app_path;     // Full path to app directory
    bool is_system_app = false;  // True for system apps (com.mosis.*)

    // Computed paths
    std::string GetEntryPath() const { return app_path + "/" + entry; }
    std::string GetIconPath() const {
        // If icon starts with /, it's an absolute/system path - don't prepend app_path
        if (!icon.empty() && icon[0] == '/') {
            return icon;
        }
        return app_path + "/" + icon;
    }
};

class AppDiscovery {
public:
    // Scan a directory for apps (folders with manifest.json)
    static std::vector<AppInfo> DiscoverApps(const std::string& apps_directory);

    // Load a single app's manifest
    static bool LoadAppManifest(const std::string& app_directory, AppInfo& info);
};

} // namespace mosis
