/*!
 * KoliBri - The accessible HTML-Standard
 */
import { r as registerInstance, h, g as getElement } from './index-Brmny3Vg.js';
import { K as KolAlertFc } from './Alert-COvq80W3.js';
import { b as watchValidator, e as watchBoolean, s as setState } from './common-DEEjER7G.js';
import { v as validateHasCloser } from './has-closer-GBI76y-L.js';
import { v as validateLabel } from './label-Cg7TG_7b.js';
import { d as dispatchDomEvent, K as KolEvent } from './events-BhfZTW2e.js';
import { w as watchHeadingLevel } from './validation-VhuthteS.js';
import './tslib.es6-QNbPBOk5.js';
import './clsx-COFh-Vc8.js';
import './component-names-Dy77vq43.js';
import './i18n-CaL2ODdQ.js';
import './i18n-B2d_exHc.js';
import './bem-registry-B9CzNnO1.js';
import './component-DHo2YdSx.js';
import './Heading-Hh3eykel.js';
import './level-CfQolHx4.js';
import './normalizers-pgU77mXp.js';
import './_Uint8Array-kJHDjtoP.js';
import './isArray-CcrBs4JM.js';

const alertTypeOptions = ['default', 'info', 'success', 'warning', 'error'];
const isAlertTypePropType = (value) => {
    return typeof value === 'string' && alertTypeOptions.includes(value);
};
const validateAlertType = (component, value) => {
    watchValidator(component, '_type', isAlertTypePropType, new Set(alertTypeOptions), value);
};

const alertVariantOptions = ['card', 'msg'];
const isAlertVariantPropType = (value) => {
    return typeof value === 'string' && alertVariantOptions.includes(value);
};
const validateAlertVariant = (component, value) => {
    watchValidator(component, '_variant', isAlertVariantPropType, new Set(alertVariantOptions), value);
};

const KolAlertWc = class {
    constructor(hostRef) {
        registerInstance(this, hostRef);
        this.close = () => {
            var _a, _b;
            (_b = (_a = this._on) === null || _a === void 0 ? void 0 : _a.onClose) === null || _b === void 0 ? void 0 : _b.call(_a, new Event('Close'));
            if (this.host) {
                dispatchDomEvent(this.host, KolEvent.close);
            }
        };
        this.handleAlertTimeout = () => {
            this.validateAlert(false);
        };
        this._alert = false;
        this._hasCloser = false;
        this._level = 0;
        this._type = 'default';
        this._variant = 'msg';
        this.state = {
            _level: 0,
        };
        this.validateOnValue = (value) => typeof value === 'object' && value !== null && typeof value.onClose === 'function';
    }
    render() {
        const { _alert, _hasCloser, _label, _level, _type, _variant } = this.state;
        const props = {
            alert: _alert,
            hasCloser: _hasCloser,
            label: _label,
            level: _level,
            type: _type,
            variant: _variant,
            onCloserClick: this.close,
            onAlertTimeout: this.handleAlertTimeout,
        };
        return (h(KolAlertFc, Object.assign({ key: 'ab90b52cbda1d61514c3acd292d0bd6d91f0c9d5' }, props), h("slot", { key: '6a7e2a89cfabde71c1140d4cf5de28e99bc09ef4' })));
    }
    validateAlert(value) {
        watchBoolean(this, '_alert', value);
    }
    validateHasCloser(value) {
        validateHasCloser(this, value);
    }
    validateLabel(value) {
        validateLabel(this, value);
    }
    validateLevel(value) {
        watchHeadingLevel(this, value);
    }
    validateOn(value) {
        if (this.validateOnValue(value)) {
            setState(this, '_on', {
                onClose: value.onClose,
            });
        }
    }
    validateType(value) {
        validateAlertType(this, value);
    }
    validateVariant(value) {
        validateAlertVariant(this, value);
    }
    componentWillLoad() {
        this.validateAlert(this._alert);
        this.validateHasCloser(this._hasCloser);
        this.validateLabel(this._label);
        this.validateLevel(this._level);
        this.validateOn(this._on);
        this.validateType(this._type);
        this.validateVariant(this._variant);
    }
    get host() { return getElement(this); }
    static get watchers() { return {
        "_alert": ["validateAlert"],
        "_hasCloser": ["validateHasCloser"],
        "_label": ["validateLabel"],
        "_level": ["validateLevel"],
        "_on": ["validateOn"],
        "_type": ["validateType"],
        "_variant": ["validateVariant"]
    }; }
};

export { KolAlertWc as kol_alert_wc };
//# sourceMappingURL=kol-alert-wc.entry.js.map
