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

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

const KolCardWc = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.translateClose = i18n.translate('kol-close');
        this.close = () => {
            var _a;
            if (((_a = this._on) === null || _a === void 0 ? void 0 : _a.onClose) !== undefined) {
                this._on.onClose(new Event('Close'));
            }
            if (this.host) {
                events.dispatchDomEvent(this.host, events.KolEvent.close);
            }
        };
        this.on = {
            onClick: this.close,
        };
        this._hasCloser = false;
        this._headingId = dev_utils.createUniqueId('card-heading');
        this._level = 0;
        this.state = {
            _label: '',
        };
        this.validateOnValue = (value) => typeof value === 'object' && value !== null && typeof value.onClose === 'function';
    }
    render() {
        return (index.h(index.Host, { key: '909cc395209bdb2eba2f674f5fe9f4b8750fccef' }, index.h("article", { key: '8bbd3d853a4ea8bc6f83dedf245414e8d9421461', "aria-labelledby": this._headingId, class: "kol-card" }, index.h(Heading.KolHeadingFc, { key: '2609f6812d8d909de20b00162cb119b32c0d7f23', class: "kol-card__header", id: this._headingId, level: this.state._level }, this.state._label), index.h("div", { key: 'a953cb61794cf76980111256849685184cc5dcf9', class: "kol-card__content" }, index.h("slot", { key: '31d86a46cb4e9d9cee62692aeea43f08db236ccb' })), this.state._hasCloser && (index.h(componentNames.KolButtonWcTag, { key: '763993312892b16856634e6d0d10de5cb1454629', class: "kol-card__close-button kol-close-button", "data-testid": "card-close-button", _hideLabel: true, _icons: {
                left: {
                    icon: 'kolicon-cross',
                },
            }, _label: this.translateClose, _on: this.on, _tooltipAlign: "left" })))));
    }
    validateHasCloser(value) {
        hasCloser.validateHasCloser(this, value);
    }
    validateLabel(value) {
        label.validateLabel(this, value, {
            required: true,
        });
    }
    validateLevel(value) {
        validation.watchHeadingLevel(this, value);
    }
    validateOn(value) {
        if (this.validateOnValue(value)) {
            common.setState(this, '_on', {
                onClose: value.onClose,
            });
        }
    }
    componentWillLoad() {
        this.validateHasCloser(this._hasCloser);
        this.validateLabel(this._label);
        this.validateLevel(this._level);
        this.validateOn(this._on);
    }
    get host() { return index.getElement(this); }
    static get watchers() { return {
        "_hasCloser": ["validateHasCloser"],
        "_label": ["validateLabel"],
        "_level": ["validateLevel"],
        "_on": ["validateOn"]
    }; }
};

exports.kol_card_wc = KolCardWc;
//# sourceMappingURL=kol-card-wc.entry.cjs.js.map
