/** @type {import('./$types').PageLoad} */
console.log(`Events - Badges [badge_id]/print +page.ts start`);

import { browser } from '$app/environment';
import { events_func } from '$lib/ae_events/ae_events_functions';

// Loads badge + template for the print page (non-blocking background refresh)
export async function load({ params, parent }) {
    const log_lvl: number = 0;

    const parent_data = await parent();
    const account_id = parent_data.account_id;
    const ae_acct = parent_data[account_id];

    if (browser) {
        const event_id = params.event_id;
        const event_badge_id = params.badge_id;

        if (event_badge_id) {
            events_func.load_ae_obj_id__event_badge({
                api_cfg: ae_acct.api,
                event_badge_id: event_badge_id,
                event_id: event_id,
                inc_template: true,
                log_lvl: log_lvl
            });
        }
    }

    return { params };
}
