"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Semifunctional_1 = require("../../../../../Class/Semifunctional");
const _ids_1 = require("../../../../_ids");
const globalComponent_1 = require("../../../../globalComponent");
class OuterHTML extends Semifunctional_1.Semifunctional {
    constructor(system) {
        super({
            fi: ['component', 'any'],
            fo: ['html'],
            i: [],
            o: ['done'],
        }, {
            input: {
                component: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_OUTER_HTML);
    }
    async f({ component, any: opt }, done) {
        const globalId = component.getGlobalId();
        const component_ = (await (0, globalComponent_1.firstGlobalComponentPromise)(this.__system, globalId));
        let html;
        if (component_.$element instanceof Text) {
            html = component_.$element.textContent;
        }
        else {
            const leaves = component_.getRootLeaves();
            const leavesHtml = [];
            for (const leaf of leaves) {
                leavesHtml.push(leaf.$element.outerHTML);
            }
            html = leavesHtml.join('\n');
        }
        done({ html });
    }
    b() {
        this._output.done.push(true);
    }
}
exports.default = OuterHTML;
//# sourceMappingURL=index.js.map