import { Registry } from '../registry/Registry.js';
export class AdvisorRegistry extends Registry {
    defaultId;
    constructor(advisors, defaultId) {
        super();
        for (const advisor of advisors) {
            this.register(advisor.id, advisor);
        }
        this.defaultId = defaultId;
    }
    /**
     * Resolves the advisor for a given request.
     *
     * Priority: explicit ID > domain match > default > first registered.
     */
    resolve(advisorId, domain) {
        if (advisorId) {
            return this.get(advisorId);
        }
        if (domain) {
            const all = this.getAll();
            const match = all.find((a) => a.domains?.some((d) => d === domain));
            if (match)
                return match;
        }
        if (this.defaultId) {
            return this.get(this.defaultId);
        }
        const all = this.getAll();
        return all.length > 0 ? all[0] : undefined;
    }
    listAll() {
        return this.getAll();
    }
}
//# sourceMappingURL=registry.js.map