'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-42b107ae.js');

const RadioGroup = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.change = index.createEvent(this, "change", 7);
    }
    componentDidLoad() {
        const isRadioChecked = this.host.querySelector('materials-radio[checked]');
        this.value = isRadioChecked ? isRadioChecked.value : null;
        this.materialsRadioNodes = Array.from(this.host.querySelectorAll('materials-radio'));
        this.materialsRadioNodes.forEach((radioEl) => {
            radioEl.addEventListener('change', (value) => this.handleEvent(value));
        });
    }
    handleEvent(event) {
        event.stopPropagation();
        this.value = event.detail;
        this.cleanNeighbors(this.value);
        this.change.emit(this.value);
    }
    cleanNeighbors(except) {
        this.materialsRadioNodes.filter(el => !except || el.value !== except).forEach(el => el.checked = false);
    }
    render() {
        return (index.h(index.Host, { class: { 'linebreak': this.linebreak } }, this.label && index.h("span", null, this.label), index.h("slot", null)));
    }
    get host() { return index.getElement(this); }
    static get style() { return ":host linebreak{display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;}"; }
};

exports.materials_radio_group = RadioGroup;
