"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Holder_1 = require("../../../../../Class/Holder");
const _ids_1 = require("../../../../_ids");
const globalComponent_1 = require("../../../../globalComponent");
class PositionObserver__ extends Holder_1.Holder {
    constructor(system) {
        super({
            fi: ['component', 'opt'],
            fo: [],
            i: [],
            o: ['entry'],
        }, {
            input: {
                component: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_POSITION_OBSERVER);
    }
    async f({ component }, done) {
        const { api: { document: { PositionObserver }, }, } = this.__system;
        const observer_callback = (x, y) => {
            this._output.entry.push({ x, y });
        };
        const observer = new PositionObserver(this.__system, observer_callback);
        this._observer = observer;
        const globalId = component.getGlobalId();
        const _component = (await (0, globalComponent_1.firstGlobalComponentPromise)(this.__system, globalId));
        const leaf = _component.getFirstRootLeaf();
        this._observer.observe(leaf.$element);
    }
    d() {
        if (this._observer) {
            this._observer.disconnect();
            this._observer = undefined;
        }
    }
}
exports.default = PositionObserver__;
//# sourceMappingURL=index.js.map