import type { PageServerLoad } from './$types';

export const load: PageServerLoad = async (event) => {
	const { url } = event;

	// Get entity info from query params if provided
	const entityType = url.searchParams.get('entityType');
	const entityId = url.searchParams.get('entityId');

	// Get pre-fill params for messaging from service/project pages
	const participantIdsParam = url.searchParams.get('participantIds');
	const conversationType = url.searchParams.get('conversationType');
	const subject = url.searchParams.get('subject');

	// Parse comma-separated participant IDs
	const participantIds = participantIdsParam
		? participantIdsParam.split(',').filter((id) => id.trim())
		: [];

	return {
		entityType,
		entityId,
		participantIds,
		conversationType,
		subject
	};
};
