import type { PageServerLoad } from './$types';
import { listImageModels } from '$lib/server/scraper';
import { log } from '$lib/server/logger';

export interface ImageModelInfo {
	id: string;
	label: string;
	provider: string;
}

export const load: PageServerLoad = async () => {
	// Parent layout already guards admin role.
	let imgModels: ImageModelInfo[] = [];
	try {
		imgModels = await listImageModels<ImageModelInfo>();
	} catch (e) {
		log.warn('admin/catalogue-tools', 'failed to load image models', { err: String(e) });
	}
	return { imgModels };
};

