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

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

const STYLE = new GlobalStyle(`
    :host {
        --logic-color-back: #ffdfe4;
        --logic-color-border: #ff0000;
    }
`);

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

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

const TPL_CAPTION = "NOT";
const REFERENCE = "not";

export default class OperatorNot extends AbstractOneChildElement {

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

    calculate(state = {}) {
        let value;
        const ch = this.children;
        if (ch[0]) {
            const val = ch[0].calculate(state);
            value = +!val;
        }
        this.shadowRoot.getElementById("header").setAttribute("value", value);
        return value;
    }

}

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