/*!
 * KoliBri - The accessible HTML-Standard
 */
'use strict';

var index = require('./index-DBbl8tEq.js');
var Alert = require('./Alert-CVPzTxE7.js');
var common = require('./common-DAAt5YQ7.js');
var hasCloser = require('./has-closer-CuErOOct.js');
var label = require('./label-VzToxIES.js');
var events = require('./events-DN9qldnr.js');
var validation = require('./validation-DwarFcC9.js');
require('./tslib.es6-Cm0ytgPY.js');
require('./clsx-Bm_HQUnh.js');
require('./component-names-5KS_pYRF.js');
require('./i18n-DL7vJXNn.js');
require('./i18n-CgUN6lev.js');
require('./bem-registry-D9uDM1GJ.js');
require('./component-C1vBQDN-.js');
require('./Heading-Cswcjs5-.js');
require('./level-VjfppjxT.js');
require('./normalizers-R90MJyQR.js');
require('./_Uint8Array-BAQUGozM.js');
require('./isArray-BOIOdEQh.js');

const alertTypeOptions = ['default', 'info', 'success', 'warning', 'error'];
const isAlertTypePropType = (value) => {
    return typeof value === 'string' && alertTypeOptions.includes(value);
};
const validateAlertType = (component, value) => {
    common.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) => {
    common.watchValidator(component, '_variant', isAlertVariantPropType, new Set(alertVariantOptions), value);
};

const KolAlertWc = class {
    constructor(hostRef) {
        index.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) {
                events.dispatchDomEvent(this.host, events.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 (index.h(Alert.KolAlertFc, Object.assign({ key: 'ab90b52cbda1d61514c3acd292d0bd6d91f0c9d5' }, props), index.h("slot", { key: '6a7e2a89cfabde71c1140d4cf5de28e99bc09ef4' })));
    }
    validateAlert(value) {
        common.watchBoolean(this, '_alert', value);
    }
    validateHasCloser(value) {
        hasCloser.validateHasCloser(this, value);
    }
    validateLabel(value) {
        label.validateLabel(this, value);
    }
    validateLevel(value) {
        validation.watchHeadingLevel(this, value);
    }
    validateOn(value) {
        if (this.validateOnValue(value)) {
            common.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 index.getElement(this); }
    static get watchers() { return {
        "_alert": ["validateAlert"],
        "_hasCloser": ["validateHasCloser"],
        "_label": ["validateLabel"],
        "_level": ["validateLevel"],
        "_on": ["validateOn"],
        "_type": ["validateType"],
        "_variant": ["validateVariant"]
    }; }
};

exports.kol_alert_wc = KolAlertWc;
//# sourceMappingURL=kol-alert-wc.entry.cjs.js.map
