// extracts quant labels from repo sibling filenames, skipping draft (MTP)
// and mmproj artifacts which are not loadable as the main model
export function quantsFromSiblings(siblings: { rfilename: string }[]): string[] {
	// TODO (Julien): i'll get that info directly from the API in the future
	const seen = new Set<string>();
	const out: string[] = [];
	for (const { rfilename } of siblings) {
		if (/mmproj|(?:^|[\/-])mtp[-.]/i.test(rfilename)) continue;
		if (!rfilename.toLowerCase().endsWith('.gguf')) continue;
		const base = rfilename
			.split('/')
			.pop()!
			.replace(/\.gguf$/i, '');
		const partMatch = base.match(/-(\d{5})-of-\d{5}$/);
		if (partMatch && partMatch[1] !== '00001') continue;
		const stripped = partMatch ? base.replace(/-\d{5}-of-\d{5}$/, '') : base;
		const m = stripped.match(/(?:^|-)((?:UD-|i1-)?(?:IQ\d|Q\d|BF\d+|F\d+|MXFP\d+|TQ\d)[\w-]*)$/i);
		const label = (m ? m[1] : stripped).toUpperCase();
		if (label.length >= 10) continue;
		if (!seen.has(label)) {
			seen.add(label);
			out.push(label);
		}
	}
	return out;
}
