export class GatewayPlatformRegistry {
    entries = new Map();
    register(entry, options = {}) {
        if (!entry.service.trim())
            throw new Error("Gateway platform service is required.");
        if (!options.replace && this.entries.has(entry.service)) {
            throw new Error(`Gateway platform already registered: ${entry.service}`);
        }
        this.entries.set(entry.service, {
            ...entry,
            capabilities: { ...entry.capabilities },
        });
    }
    has(service) {
        return this.entries.has(service);
    }
    get(service) {
        const entry = this.entries.get(service);
        if (!entry)
            return undefined;
        return {
            ...entry,
            capabilities: { ...entry.capabilities },
        };
    }
    require(service) {
        const entry = this.get(service);
        if (!entry)
            throw new Error(`Unsupported gateway platform: ${service}`);
        return entry;
    }
    list() {
        return [...this.entries.values()]
            .map((entry) => ({
            ...entry,
            capabilities: { ...entry.capabilities },
        }))
            .sort((a, b) => a.service.localeCompare(b.service));
    }
}
export const defaultGatewayPlatformRegistry = new GatewayPlatformRegistry();
//# sourceMappingURL=platform-registry.js.map