"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../../Class/Functional");
const cloneBundle_1 = require("../../../../../spec/cloneBundle");
const _ids_1 = require("../../../../_ids");
class RemoveChild extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['parent', 'at'],
            o: ['unit'],
        }, {
            input: {
                parent: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_REMOVE_CHILD);
    }
    f({ parent, at }, done) {
        let unit;
        try {
            const child = parent.removeChild(at);
            unit = (0, cloneBundle_1.cloneBundle)(child);
            child.destroy();
        }
        catch (err) {
            done(undefined, err.message);
            return;
        }
        done({
            unit,
        });
    }
}
exports.default = RemoveChild;
//# sourceMappingURL=index.js.map