/** @type {import('./$types').LayoutLoad} */
console.log(`ae_events_badges +layout.ts start`);

import { events_func } from '$lib/ae_events_functions';

export async function load({ parent }) {
	const data = await parent();
	// console.log(`ae_events_badges +layout.ts data:`, data);

	const account_id = data.account_id;
	const ae_acct = data[account_id];
	console.log(`ae_acct = `, ae_acct);

	if (!account_id) {
		console.log(`events_badges +layout.ts: The account_id was not found in the data!!!`);
		return false;
	}

	const event_id = ae_acct.slct.event_id;
	if (!event_id) {
		console.log(`events_badges +layout.ts: The event_id was not found in the data!!!`);
		return false;
	}

	const load_event_obj = events_func.load_ae_obj_id__event({
		api_cfg: ae_acct.api,
		event_id: event_id,
		try_cache: true
	});

	ae_acct.slct.event_obj = load_event_obj;

	const submenu = {
		main: { name: 'Main', href: '/events_badges', access: false },
		// manage: {name: 'Manage', href: '/events_badges/manage', access: 'administrator', disable: true, hide: true},
		review: {
			name: 'Review',
			href: '/events_badges/review',
			access: false,
			disable: false,
			hide: false
		}
		// print: {name: 'Print', href: '/events_badges/print', access: 'trusted', disable: true, hide: false},
		// view: {name: 'View', href: '/events_badges/view', access: 'trusted', hide: true}, // event_badge_id
		// new: {name: 'New', href: '/events_badges/new'},
		// sponsorships: {name: 'Sponsorships', href: '/sponsorships', disable: true, hide: true},
	};
	data.submenu = submenu;

	// WARNING: Precaution against shared data between sites and sessions.
	data[account_id] = ae_acct;

	return data;
}

// export const prerender = false;
// export const prerender = true;
