import { api } from '../lib/api';
import { log } from '$lib/cot-logger';

// #region load:Function [C:2] [TYPE Function]
// @BRIEF Loads initial plugin data for the dashboard.
// @POST Returns an object with plugins or an error message.
/** @type {import('./$types').PageLoad} */
export async function load() {
    try {
        const plugins = await api.getPlugins();
        return {
            plugins
        };
    } catch (error) {
        log("HomePage", "EXPLORE", "Failed to load plugins", {}, String(error));
        return {
            plugins: [],
            error: 'Failed to load plugins'
        };
    }
}
// #endregion load:Function
