"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../Class/Functional");
const _ids_1 = require("../../../_ids");
class Transfer extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['window', 'opt', 'data'],
            o: [],
        }, {
            input: {
                window: {
                    ref: true,
                },
                data: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_TRANSFER);
    }
    async f({ window, data }, done) {
        try {
            let transferable;
            try {
                transferable = await data.raw();
            }
            catch (err) {
                done(undefined, err.message);
                return;
            }
            window.postMessage(transferable, '*', [transferable]);
        }
        catch (err) {
            done(undefined, err.message);
            return;
        }
        done();
    }
}
exports.default = Transfer;
//# sourceMappingURL=index.js.map