"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Element_ = void 0;
const Stateful_1 = require("../Stateful");
class Element_ extends Stateful_1.Stateful {
    constructor({ i = [], o = [] }, opt = {}, system, id) {
        super({
            i,
            o,
        }, opt, system, id);
        this.__ = ['U', 'C', 'J', 'V', 'EE'];
        this.addListener('reset', () => {
            this.emit('call', { method: 'reset', data: [] });
        });
        this.addListener('set', (name, data) => {
            const { api: { window: { nextTick }, }, } = this.__system;
            if (!this._forwarding) {
                if (data === undefined) {
                    this._forwarding_empty = true;
                    // @ts-ignore
                    this._output?.[name]?.pull();
                    this._forwarding_empty = false;
                }
                else {
                    this._forwarding = true;
                    // @ts-ignore
                    this._output?.[name]?.push(data);
                    this._forwarding = false;
                }
            }
            if (!this._set_from_input &&
                !this._backwarding &&
                !this._forwarding &&
                data !== undefined) {
                this._backwarding = true;
                nextTick(() => {
                    this._input?.[name]?.pull();
                    this._backwarding = false;
                });
            }
        });
        this._slot = {
            default: this,
        };
    }
    isElement() {
        return true;
    }
}
exports.Element_ = Element_;
//# sourceMappingURL=index.js.map