/* ===================== AUTOGENERATED SOURCE IMPORT ===================== */

import GlobalStyle from "/emcJS/util/html/template/CSSTemplate.js";

const STYLE = new GlobalStyle(`
    :host {
        --logic-color-back: repeating-linear-gradient(145deg, #bcdefb, #bcdefb 20px, #ffdfe4 20px, #ffdfe4 40px);
        --logic-color-border: #37a3ff;
    }
`);

/* ======================================================================= */

import AbstractElement from "../abstract/AbstractElement.js";
import AbstractInfChildrenElement from "../abstract/AbstractInfChildrenElement.js";

const TPL_CAPTION = "NOR";
const REFERENCE = "nor";

export default class OperatorNor extends AbstractInfChildrenElement {

    constructor() {
        super(REFERENCE, TPL_CAPTION);
        STYLE.apply(this.shadowRoot);
    }

    calculate(state = {}) {
        const ch = this.childList.map((node) => node.calculate(state));
        for (const val of ch) {
            if (val) {
                this.shadowRoot.getElementById("header").setAttribute("value", "0");
                return 0;
            }
        }
        this.shadowRoot.getElementById("header").setAttribute("value", "1");
        return 1;
    }

}

AbstractElement.registerReference(REFERENCE, OperatorNor);
customElements.define(`emc-logic-${REFERENCE}`, OperatorNor);
