/** @type {import('./$types').LayoutLoad} */

// Data loading for IDAA Recovery Meetings has been moved to the $effect in +page.svelte
// (gated on novi_verified / trusted_access). +layout.ts runs before layout effects and
// fires during SvelteKit link prefetch, making it unsafe for private IDAA content.

export async function load({ params, parent }) {
    const log_lvl: number = 0;

    const data = await parent();
    data.log_lvl = log_lvl;

    const account_id = data.account_id;
    let ae_acct = data[account_id];

    if (!ae_acct) {
        console.warn(
            `ae IDAA Recovery Meetings +layout.ts: Account ${account_id} not found in data. Initializing ghost acct.`
        );
        ae_acct = {
            api: data.ae_api || {},
            slct: { account_id: account_id }
        };
    }

    data[account_id] = ae_acct;
    return data;
}
