'use strict';

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

const core = require('./core-c57a47e8.js');

const RadioGroup = class {
    constructor(hostRef) {
        core.registerInstance(this, hostRef);
        this.change = core.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 (core.h(core.Host, { class: { 'linebreak': this.linebreak } }, this.label && core.h("span", null, this.label), core.h("slot", null)));
    }
    get host() { return core.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;
