package com.tiedup.remake.client.gltf.diagnostic;

import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;

/**
 * Static client-side registry of GLB validation results.
 * Populated during resource reload, queried by /tiedup validate command.
 */
@OnlyIn(Dist.CLIENT)
public final class GlbDiagnosticRegistry {

    private static final Map<ResourceLocation, GlbValidationResult> results =
        new LinkedHashMap<>();

    private GlbDiagnosticRegistry() {}

    public static void clear() {
        results.clear();
    }

    public static void addResult(GlbValidationResult result) {
        results.put(result.source(), result);
    }

    public static Collection<GlbValidationResult> getAll() {
        return Collections.unmodifiableCollection(results.values());
    }

    public static List<GlbValidationResult> getErrors() {
        return results.values().stream()
            .filter(r -> !r.passed())
            .toList();
    }

    public static GlbValidationResult get(ResourceLocation source) {
        return results.get(source);
    }

    public static int size() {
        return results.size();
    }
}
