export class AssetRegistry {
    loaders = new Map();
    register(loader) {
        if (this.loaders.has(loader.type)) {
            throw new Error(`Asset loader type already registered: ${loader.type}`);
        }
        this.loaders.set(loader.type, loader);
    }
    unregister(type) {
        return this.loaders.delete(type);
    }
    get(type) {
        const loader = this.loaders.get(type);
        if (!loader) {
            throw new Error(`No asset loader registered for type: ${type}`);
        }
        return loader;
    }
    find(request) {
        if (request.type) {
            return this.get(request.type);
        }
        for (const loader of this.loaders.values()) {
            if (loader.canLoad(request)) {
                return loader;
            }
        }
        throw new Error(`No asset loader can load ${request.url}`);
    }
    list() {
        return [...this.loaders.keys()];
    }
}
//# sourceMappingURL=AssetRegistry.js.map