import { HealthCheckService } from '../core/backend-api/index.js';
import { tryExecute } from '../core/resources/index.js';
import { UmbControllerBase } from '../../libs/class-api/index.js';
import { UmbBasicState } from '../../libs/observable-api/index.js';
// TODO: Check whats up with this code, this is not a context, this is a controller... [NL]
export class UmbHealthCheckContext extends UmbControllerBase {
    constructor() {
        super(...arguments);
        this.#checks = new UmbBasicState(undefined);
        this.checks = this.#checks.asObservable();
        this.#results = new UmbBasicState(undefined);
        this.results = this.#results.asObservable();
    }
    #checks;
    #results;
    async getGroupChecks(name) {
        const { data } = await tryExecute(this, HealthCheckService.getHealthCheckGroupByName({ path: { name } }));
        if (data) {
            this.#checks.setValue(data);
        }
        else {
            this.#checks.setValue(undefined);
        }
    }
    async checkGroup(name) {
        const { data } = await tryExecute(this, HealthCheckService.postHealthCheckGroupByNameCheck({ path: { name } }));
        if (data) {
            this.#results.setValue(data);
        }
        else {
            this.#results.setValue(undefined);
        }
    }
    static isInstanceLike(instance) {
        return typeof instance === 'object' && instance.results !== undefined;
    }
}
export default UmbHealthCheckContext;
