var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { UMB_HEALTHCHECK_DASHBOARD_CONTEXT } from '../health-check-dashboard.context.js';
import { css, html, customElement, state } from '../../../external/lit/index.js';
import { UmbLitElement } from '../../core/lit-element/index.js';
import './health-check-group-box-overview.element.js';
import { UmbTextStyles } from '../../core/style/index.js';
let UmbDashboardHealthCheckOverviewElement = class UmbDashboardHealthCheckOverviewElement extends UmbLitElement {
    constructor() {
        super();
        this.consumeContext(UMB_HEALTHCHECK_DASHBOARD_CONTEXT, (instance) => {
            this._healthCheckDashboardContext = instance;
        });
    }
    async _onHealthCheckHandler() {
        this._buttonState = 'waiting';
        await this._healthCheckDashboardContext?.checkAll();
        this._buttonState = 'success';
    }
    render() {
        return html `
			<uui-box>
				<div id="header" slot="header">
					<h2>Health Check</h2>
					<uui-button
						label="Perform all checks"
						color="positive"
						look="primary"
						.state="${this._buttonState}"
						@click="${this._onHealthCheckHandler}">
						Perform all checks
					</uui-button>
				</div>
				<div class="grid">

					${
        // As well as the visual presentation, this amend to the rendering based on button state is necessary
        // in order to trigger an update after the checks are complete (this.requestUpdate() doesn't suffice).
        this._buttonState !== 'waiting'
            ? html `<umb-extension-slot
									type="healthCheck"
									default-element="umb-health-check-group-box-overview"></umb-extension-slot>`
            : html `<uui-loader></uui-loader>`}
					</umb-extension-slot>
				</div>
			</uui-box>
		`;
    }
    static { this.styles = [
        UmbTextStyles,
        css `
			:host {
				display: block;
				padding: var(--uui-size-layout-1);
			}

			uui-box + uui-box {
				margin-top: var(--uui-size-space-5);
			}

			#header {
				width: 100%;
				display: flex;
				justify-content: space-between;
				align-items: center;
			}

			#header h2 {
				font-size: var(--uui-type-h5-size);
				margin: 0;
			}

			.grid {
				display: grid;
				gap: var(--uui-size-space-4);
				grid-template-columns: repeat(auto-fit, minmax(250px, auto));
			}
		`,
    ]; }
};
__decorate([
    state()
], UmbDashboardHealthCheckOverviewElement.prototype, "_buttonState", void 0);
UmbDashboardHealthCheckOverviewElement = __decorate([
    customElement('umb-dashboard-health-check-overview')
], UmbDashboardHealthCheckOverviewElement);
export { UmbDashboardHealthCheckOverviewElement };
export default UmbDashboardHealthCheckOverviewElement;
